Created
November 5, 2008 22:08
-
-
Save sbrocket/22448 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int cols = 2; | |
int rows = 3; | |
float levelData[cols][rows] = {5.66, 11.06, 16.49, 0, 0, 0}; | |
NSMutableData *writeOut = [NSMutableData dataWithCapacity:cols*rows*sizeof(float)]; | |
for (int i=0; i < cols; ++i) | |
[writeOut appendBytes:(void*)levelData[i] length:rows]; | |
[writeOut writeToFile:somePath atomically:YES]; | |
NSData *readIn = [NSData dataWithContentsOfFile:somePath]; | |
float** newArray = (float**)malloc(cols*sizeof(float*)); | |
for (int col=0; col < cols; ++col) | |
newArray[col] = (float*)malloc(rows*sizeof(float)); | |
for (int col=0; col < cols; ++col) | |
for (int row=0; row < rows; ++row) | |
newArray[col][row] = ((float*)readIn.bytes)[col*rows+row]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment