c++ - Reading whitespace from char -


i writing program practice need read text file , convert lowercase.

ifstream file("words.txt"); char c;  while(file >> c) {     if(isupper(c)) c = tolower(c);     cout << c; } 

this program simple enough, if want print file contents using same loop skip spaces.

while(getline(file, str)) {     cout << str << endl; } 

if made string str , did while loop read file contents not print anything. ideal goal able read file, convert each char lowercase, , print text spaces included, preferably without repeating loops , writing lots of un-necessary code.


Comments

Popular posts from this blog

sql - Time in datatime field -

javascript - How to split the success output from an Ajax post? -

java - sharing object across different classes -