+ 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; }
7 Réponses
+ 8
so you want the name to be all capital letters?
+ 8
John is correct. c is never used.
+ 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
+ 2
Thank you all! I will try to fix it now
+ 1
Yes