i am working to make a translating software from an Urdu sentence into Hindi and vice versa, i am using visual c++ 2010 software with c++ language. i have written an Urdu sentence in a text file. now i want to get a single character one by one from that file so that i can work on it to convert it into its equivalent Hindi character. when i use get() function to get a single character from input file and write this single character on output file, i get some unknown ugly looking character placed in output file. kindly help me with proper code. my code is as follows
Code:#include<iostream> #include<fstream> #include<cwchar> #include<cstdlib> using namespace std; void main() { wchar_t arry[50]; wifstream inputfile("input.dat",ios::in); wofstream outputfile("output.dat"); if(!inputfile) { cerr<<"File not open"<<endl; exit(1); } int i=0; while ( ! inputfile.eof() ) // i am using this while just to // make sure copy-paste operation of // written urdu text from one file to // another. get() function used // in this way works well but when i // try to pick only one character from // file, it does not work. { arry[i] = inputfile.get(); outputfile<<arry[i]; i++; } inputfile.close(); outputfile.close(); cout<<"Hello world"<<endl; }


Reply With Quote
Bookmarks