Can someone explain this line a bit for me, I get the big picture, but the under-the-hood aspects are eluding me.
testFile.getline(buffer, sizeof(buffer));
I have a char array buffer of size 80. Get line extracts a line from my testFile, and puts it into the buffer. When I "cout" the buffer it only prints the line I grabbed, but if I scroll through the entire buffer I get all the junk at the end. I guess what I'm asking is, does getline slap a '\0' at the end of the chars it extracts from the file? Is this why "cout" doesn't spew all the garbage from the unused elements in the char array?
with the following code:
testFile.getline(buffer, sizeof(buffer));
int a = 0;
while(buffer != '\0')
{
cout << buffer[a];
a++;
}
This prints the line it grabbed and just keeps a rolling spewing seemingly every ascii char known to man, over and over beeping and a booping ad-infinatum. I don't get it.