I am facing a strange problem with my application, and although I have tried many solutions, someone I have not even solved my problem.
My C ++ application generates a set of files with custom data. So far, the code works fine, and the file is generated correctly, the first one Except for the expected format of the files is:
@header @ line1e1, line1e2, line1e3 line2e1, line2e2, line1e3
However, I have seen a strange spaces (and only the first one) on the first line of the first generated file:
@headers @ line1e 1 , Line 1A2, Line 1E3 Line2E1, Line2A2, Line1E3
Since the code is the same for all the files, I am thinking that this Wrong, but so far I am unable to locate the root cause of my problem.
The following is a simplified version of my code:
/ * variable * / std :: ofstream fil; Std :: stringstream ss; s. Precision (10); Ss.width (10); Ss.setf (iOS :: Fixed); {Sprintf (FilNam, "% i-ExportFile.txt", Inx) for (Inte Inks = 0; Inks & lt; MaxInx; Inx ++); Fil.open (std :: string (FilNam). C_str (), std :: ofstream :: out); SavSta = Fil.is_open (); If (surveyor) {SS & lt; & Lt; "@Hedder" & lt; & Lt; "\ N"; SS & lt; & Lt; "@MetricsName:" & lt; & Lt; MTCAnames & lt; & Lt; "\ N"; SS & lt; & Lt; / * Matrix data goes here * / & lt; & Lt; "\ N"; File & lt; & Lt; Ss.rdbuf (); Ss.str (std :: string ()); Ss.clear (); } Fil.close (); }
Coming from:
Ss .width (10);
If the standard width of the representation is less than the breadth of the field, then the presentation is padded with fill letters
Just remove it and you'll be fine.
No comments:
Post a Comment