I'm wondering what is the accepted way of getting input from the command line which captures white space as well. I thought this would do it...
char text[500];
int textSize = 0;
int main() {
while (!cin.eof()) {
cin >> text[textSize];
textSize++;
}
for(int i = 0; i < textSize; i++) {
cout << text[i];
}
return 0;
}
But looks like it skips white space. I switched to this...
char c;
while ((c = getchar()) != EOF) {
text[textSize] = c;
textSize++;
}
which works perfectly but I know this from a C programming book. Wondering how I would handle it in c++