faz <fa*********@gm ail.comwrote in message...
/* """ quote
But the array should consider 0-41(42 bits)
int main(){
char ch;
char revStr[41],correctStr[41];
int count=0
ifstream in("config.txt" ,ios::in | ios::binary);
if(!in){
cout << "Cannot open read file.";
return 1;
}
while(in){ // in will be false when eof is reached
in.get(ch);
if(in){
cout << ch;
correctStr[count]=ch;
count++;
}
}
correctStr[count]='\0';
fn_revrs(correc tStr,revStr,cou nt);
cout<<"\nno of characters in file :"<<count<<endl ;
cout<<"correct set of characters in file :\n"<<correctSt r<<endl;
cout<<"rev of characters in file :\n"<<revStr<<e ndl;
}
file://config.txt
001010000000000 000000000110000 000000000100
pls suggest me where i am wrong...
regards, fazal
""" */ quote end
Is this homework?
// --------
// .....
std::ifstream in("config.txt" , std::ios_base:: in|std::ios_bas e::binary );
if( not in ){
cout << "Cannot open read file.";
return 1;
}
while( in.get( ch ) ){
cout << ch;
correctStr[ count++ ] = ch;
}
// .....
// --------
If NOT homework:
#include <iostream>
#include <string>
#include <fstream>
#include <algorithm// for copy, reverse
#include <iterator // for istream_iterato r
// + any I missed <G>
int main(){
std::ifstream in( "config.txt " );
std::string Sdata;
std::copy( std::istream_it erator<char>( in ),
std::istream_it erator<char>(),
std::back_inser ter( Sdata ) ); // put file in string
std::cout<<"\nS data size="<<Sdata.s ize()<<'\n';
std::cout<<"Sda ta="<<Sdata<<st d::endl;
if( 8 < Sdata.size() ){
std::cout<<"\nT he 9th char is "<<Sdata.at ( 8 )<<std::endl;
}
std::string RevIt( Sdata );
std::reverse( RevIt.begin(), RevIt.end() ); // reverse it
std::cout<<"Rev It="<<RevIt<<st d::endl;
return 0;
} // main()
--
Bob R
POVrookie