how to get a single wide character (wchar_t) one by one from *.txt file in c++??

i am working on Urdu Hindi translation/transliteration. my objective is to translate 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(i.e ثاقب مقبول سکول جاتا ھے) 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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#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;

}
IIRC inputfile.get() returns an integer

why not
1
2
3
4
5
wchar_t wc;
while(inputfile.get(wc))
{
  outputfile.put(wc);
}
Topic archived. No new replies allowed.