Need help with removing characters and making all letters uppercase but keep spaces in the .txt. | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 2

Need help with removing characters and making all letters uppercase but keep spaces in the .txt.

#include <iostream> #include <string> #include <fstream> using namespace std; int main() { ifstream inFile; inFile.open("corpus.txt"); ofstream NewName; NewName.open("corpus_clean.txt"); string thebook; while (!inFile.eof()) { inFile >> thebook; int j; for ( j=0; j<thebook.length(); j++) { char c; c=thebook[j]; if(isalpha(c) || (c =' ')); c = toupper(c); NewName<<thebook[j]; } cout<<thebook; } system("pause"); return 0; }

21st Sep 2017, 9:47 PM
Anastasia
5 Antworten
+ 8
so you want the name to be all capital letters?
21st Sep 2017, 10:04 PM
jay
jay - avatar
+ 8
John is correct. c is never used.
21st Sep 2017, 10:07 PM
jay
jay - avatar
+ 6
You capitalize c then you use thebook[j]. I'm not sure what you are expecting. Please show original and results. Test line -> TEST LINE
21st Sep 2017, 10:04 PM
John Wells
John Wells - avatar
+ 2
Thank you all! I will try to fix it now
21st Sep 2017, 10:58 PM
Anastasia
+ 1
Yes
21st Sep 2017, 10:04 PM
Anastasia