Hello guys I'm writing a test file for a program. where all the possible numbers are tested and i want the result to be logged as a .csv file,so i can upload it into excel.
float calc (float i, float j , float p, float ex){
float nodalatio = (p/ex);
float ans = (0.68 *j + 1.22*nodalatio + 0.34*j -0.81);
return ans;
}
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
float stage , grade, pos, ex;
float resul;
for (int i=1;i<=3;i++){
stage = i;
for(int j=1;j<=3;j++){
grade = j;
for(int p=1;p<=60;p++){
pos = p;
for(int e=1;e<=60;e++){
ex=e;
resul = calc(stage, grade,pos,ex);
NSLog(@"stage is %f grade is %f,pos is %f ex is %f the result is %f",stage,grade,pos,ex,resul);
}
}
}
}
[pool drain];
return 0;
}
the above is the test code and i can't seem to figure how to output this in to a .csv file. does the code in the loop or after the loop. this is what i had but this did nothing !
NSString *file_path = @"test.csv";
NSString *test_1 = [NSString stringwithformat@"%f",resu];
[test_1 writeToFile:file_path atomically:YES encoding:NSUnicodeStringEncoding error:nil];
thank you