Hello! I'm trying to figure out how to create a program that prints the first letter of every line in a file, but I'm at a bit of a loss as to how to only take in one letter and move to the next line within the file. If someone could let me know as to how to move to the next line within a file, I think I could figure the rest out on my own. Thank you!
(I've attempted the problem, but couldn't get very far.)
In your own code, this is an uninitialised pointer:
char*output;
and then this line
inFile >> output;
attempts to read a string into the memory location pointed to. This gives undefined behaviour - the program is likely to crash - if it doesn't you are unlucky. (better the program crash so you realise something is wrong).
If you want to use a string, then use std::string instead of messing about with character pointers - it is safer - there's no danger of an uninitialised pointer, or of the string being too long to fit.
If someone could let me know as to how to move to the next line within a file,
The simplest way is to use getline() as in the example given.