#include<iostream>
#include<cstring>
#include<fstream>
#include<cctype>
using namespace std ;
int main(){
int counter1 = 0 , counter2 = 0 , i =0 ;
char cstr[500] ;
ifstream fin ;
fin.open("paragraph.txt");
while(!fin.eof() ) {// eof = end of file
fin.get(cstr , 500 );
for( ; i<strlen(cstr) ; i++ ) {
if( cstr[i] >= 'a' && cstr[i] <= 'z' ) {
counter1++ ;
toupper(cstr[i]);
}else if ( cstr[i] >= 'A' && cstr[i] <= 'Z' ) {
counter2++ ;
tolower(cstr[i]);
}
}
}
cout<<cstr<<endl;
cout<<" capital case : " << counter2 << " <=|=|=> small case : " <<counter1 ;
return 0 ;
}
i have a text in my paragraph file and i want to convert each capital letter with its small case and vice verse. i can't find any error with my codes and the counters work fine so my nothing wrong with my codes
Aucun commentaire:
Enregistrer un commentaire