strings and file i/o
I have what is hopefully a simple question:
I'm reading input from a file with the usual statement:
The file contains simple statements of 2 or 3 words, separated by spaces, one statement per line.
How can I get the input from the file in string format? I have tried every C++ trick I can think of (and even a few that I don't really understand!) but still can't get it to work. I need strings so that I can compare substrings to pre-defined variables
- infile.getline(...) doesn't work, it needs an array of char's as it's first parameter, not a string
- infile >> string_name doesn't work because the string is cut off at the first space
Is it possible?
Global getline() will take a string as an argument -
strings and file I/O
char arr//depends upon the number os characters in ur file.
there u have it..ur problem solved.!