So I'm still working on this project. I got the file saving feature working like I wanted it to a while back. Basically it creates an array of characters and then saves them to a file with the current date and time as the file name. This worked well for a few days.
Then I added in serial port code(which I'll post later, because there's no simple examples around), and the file saving no longer works! One of the features is for the program to save the most recent 'packet' of characters to a file that's always there, so that a user can easily see what the last sent packet was. So the i/o works, but file creation does not.
I've been over and over this(I've had professors look at it too, and they don't see anything wrong). The thing that really gets me is that this worked a few days ago, and I don't remember changing anything in this part of the code.Code:time_t rawtime; struct tm * timeinfo; char buffer [80]; memset(buffer, '\0', 80); time ( &rawtime ); timeinfo = localtime ( &rawtime ); cout << endl; string file2; string filePath = "C:\\packets\\sent"; strftime(buffer,80, "%a_%b_%d__%H_%M_%S__%Y", timeinfo); string fileName = buffer; fileName += ".txt"; file2 = filePath + "\\javacomport.txt"; filePath += "\\" + fileName; string packetString = ""; cout << filePath << endl; char fullName[100]; char full2[80]; for(int i = 0; i < filePath.length(); i++) { fullName[i] = filePath[i]; } for(int i = 0; i < file2.length(); i++) { full2[i] = file2[i]; } for(int i = 0; i < ready_sizepkt; i++) { packetString += ready_packet[i]; } ofstream packetsent(fullName); ofstream javaport(full2); if(!packetsent) { cout << "file not open\n"; } packetsent << packetString << endl; javaport << packetString << endl; packetsent.close(); javaport.close();
Hoping you guys can see something I've missed.
-System_159