Comment detail

固定長データ (Nested Flatten)

開発環境: Mac OS X 10.5.2 Xcode 3.1 (Beta)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#import <Foundation/Foundation.h>

#define FilePath @"fixedlengthdata.txt"
const unsigned int RecordSize = 12 + 12 + 1 + 3 + 4 + 2 + 31 * 1502;
const unsigned int RecordCount = 500;

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
    NSData* data = [NSData dataWithContentsOfMappedFile:FilePath];
    if ( data ) {
        NSMutableArray* array = [NSMutableArray array];
        for ( int i = 0; i < RecordCount; i++ )
            [array addObject:[data subdataWithRange:NSMakeRange( i * RecordSize, RecordSize )]];
    }
    
    [pool drain];
    return 0;
}

Index

Feed

Other

Link

Pathtraq

loading...