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

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -