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.

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...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.