0

I need the program to read 2 pieces of data from each line of a text.

For example my txt is:

A Garbage
B Garbage2
A Garbage3
A Garbage4
A Garbage5
B Garbage3
B Garbage

Now IIRC the getline function breaks after the first space. The program is supposed to perform a certain task, (decrementing and incrementing) based on the first character, and then add the following string to a stack.

I'm just wondering if I'm wrong on the getline, or how I would be able to do this (read first character, skip the space, read in the string) and then work off that. Any help or references would be appreciated because I've only seen code that uses text as a single line of string in a .txt file.

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by WaltP
0

Yes, you are wrong. Look closer at the name of the function -- getline(). Look up I/O techniques, try something, and if it doesn't work, post what you tried.

One technique is to read a character and save it, read another and ignore it, read the rest of the line. Many other possibilities are available, too. Try something...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.