U
utab
Hi there,
I am trying to read from a file and at the same time change certain
fields of the same field, there are 6 fields in this file like
1 2 3 4 5 6
--------/--------/--------/--------/--------/--------/ // field_width=8
For example, I position my file pointer at the begining of the 4th
fileld lets say 25th character(3*(field_width)+1) and when I try to
write to fields 4 5 6 with
inoutFile << setw(8) << setiosflags(ios::right) << "sometext";
inoutFile << setw(8) << setiosflags(ios::right) << "sometext";
inoutFile << setw(8) << setiosflags(ios::right) << "sometext";
and then I would like to go to the newline with
inoutFile.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
// go to the newline
but in the original file I read; the 6th field is not 8 characters
width. So By writing on that field maybe I am writing over the newline
character as well but do not know for sure. SO MAYBE I NEED TO ADD A
NEWLINE CHAR TO THE END BUT HOW??
In this form I get a SEGMENTATION FAULT error.
Any help will be very much appreciated because I can not find my error
for the last 2 days and I am going mad :-(((((( .
Thanks in advance.
I am trying to read from a file and at the same time change certain
fields of the same field, there are 6 fields in this file like
1 2 3 4 5 6
--------/--------/--------/--------/--------/--------/ // field_width=8
For example, I position my file pointer at the begining of the 4th
fileld lets say 25th character(3*(field_width)+1) and when I try to
write to fields 4 5 6 with
inoutFile << setw(8) << setiosflags(ios::right) << "sometext";
inoutFile << setw(8) << setiosflags(ios::right) << "sometext";
inoutFile << setw(8) << setiosflags(ios::right) << "sometext";
and then I would like to go to the newline with
inoutFile.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
// go to the newline
but in the original file I read; the 6th field is not 8 characters
width. So By writing on that field maybe I am writing over the newline
character as well but do not know for sure. SO MAYBE I NEED TO ADD A
NEWLINE CHAR TO THE END BUT HOW??
In this form I get a SEGMENTATION FAULT error.
Any help will be very much appreciated because I can not find my error
for the last 2 days and I am going mad :-(((((( .
Thanks in advance.