Hey. I am fairly new to C++ and can't figure out how to read set value of characters from a input file into a c-type string. I need to be able to read one string of 20 characters (like a heading to the file) then keep reading different variables of certain length, with spaces in some of them.
I figured something like this would work but I got strange output. I know the >> operator skips whitespace, but I couldn't figure out how to get around this with getline.
C style strings are terminated by nul characters. Your arrays were not large enough to hold both the extracted input and a nul character, which is why you're seeing the miscellaneous crap in your output.