I've wanted to write a program to read the extended characters from a file.
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
char a,ch[50];
long l, m, k;
ifstream infile;
infile.open("as6.txt");
l = infile.tellg();
infile.seekg(0, ios::end);
m = infile.tellg();
k = (m - l);
infile.seekg(0, ios::beg);
while(infile!=0)
{
infile.get(ch,50);
cout << ch;
}
infile.close();
cout << endl << k;
cin.get();
return 0;
}
The output is displayed as :
┼╜:♀╤ô1∞↑∩▬Zσô*▓ws┐Q
49
Wheras the output from the text file is :
Ž:Ñ“1ìïZå“*²ws¿Qœu!¥¶T›ö–ŽFŠsÙJr¯f¥åðXîRÇ?ù
I tried opening the file in binary format :
┼╜:♀╤ô1∞↑∩▬Zσô*▓ws┐Q→£u!Ñ╢T¢÷ûÄFès┘Jr»fÑ≡XεR╟?∙
Now some charcters are displayed,other not!
Completely different symblos !! First i thought the console window couldn't print those charcters so i worte another program
#include <iostream>
int main()
{
char a = 156;
unsigned int b = int (a);
std::cout << a;
std::cout << b;
std::cin.get();
return 0;
}
It prints the character perfectly in this instance.
How do i correct it ?