Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delimiters

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
hey there!
im using int's and arrays and saving the to a text file in my program. normally using space or \n as a delimiter to read the ints, i want to read the string/array and ignore the spaces. SO, when i saved to a file i put a '*' (star) on either side of the array. Now i want to read to file using the * as the delimiter that starts/ends the array. so far it looks something like:

char g[100];
while (InFile != NULL)
{
.............
InFile.ignore(1,'*');
InFile.getline(g,101,'*');
.............
}
However, I am not getting the right input when reading....
can anyone help??? thank you for your time.
 

ifstream infile("input.txt");
char buffer[1024];

// get everything up to the first * and leave
// file pointer at next character
infile.getline(buffer,1024,'*');

// infile now has the entire array plus a *
// at the end of the buffer
infile.getline(buffer,1024,'*');

// remove the * and parse the buffer for characters

Matt

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top