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

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -