I just recent started working with Xcode 4 and I'm trying to update some code that I originally ported from Matlab to Xcode 3.something. The problem I'm having is that when the code looks for a parameter file and finds that it's not there it should create a default file. However, I'm just getting a blank file.
The problem seems to resolve around file i/o, but I can't figure it out. I created a test that helped partially illuminate the problem with the following code:
int fred;
fred=126;
ofstream myFile("thisfile.txt");
myFile << "This is my message: ";
myFile << "bob" << endl;
myFile << "fred";
myFile << fred << 125 << "bob" << endl;
myFile.close();
I received this as output:
This is my message: bob
fred
Note that none of the numerical values showed up. If I move the 'fred' variable earlier in the steam the latter text doesn't show up either. It seems that as soon as a non-string value is introduced to the stream that it stops working. This was certainly not in issue in Xcode3, and I'm at a loss as to how to fix the problem I'm having. I don't want to output strings, I want to be able to output numbers as I used to.
Any ideas?
The problem seems to resolve around file i/o, but I can't figure it out. I created a test that helped partially illuminate the problem with the following code:
int fred;
fred=126;
ofstream myFile("thisfile.txt");
myFile << "This is my message: ";
myFile << "bob" << endl;
myFile << "fred";
myFile << fred << 125 << "bob" << endl;
myFile.close();
I received this as output:
This is my message: bob
fred
Note that none of the numerical values showed up. If I move the 'fred' variable earlier in the steam the latter text doesn't show up either. It seems that as soon as a non-string value is introduced to the stream that it stops working. This was certainly not in issue in Xcode3, and I'm at a loss as to how to fix the problem I'm having. I don't want to output strings, I want to be able to output numbers as I used to.
Any ideas?