there is an error when i use fread() , here`s the problem
Code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(int argc,char *argv[])
{
FILE *out;
FILE *in;
wchar_t *ch;
if((ch=(wchar_t *)malloc(sizeof(wchar_t))) == NULL)
{
printf("Error: No enough memory\n");
getchar();
return 1;
}
in = fopen("test.txt","rb");
out = fopen("output.txt","wb");
if(in == NULL)
{
printf("Can`t open file:%s\n",argv[1]);
exit(0);
}
while(fread(ch,sizeof(wchar_t),1,in) > 0)
{
printf("%d\n",ch);
fwrite(ch,sizeof(wchar_t),1,out);
}
fclose(in);
fclose(out);
return 0;
}
test.txt include the char
and if i read it and printf it using :
it output this number :
2824864
why ??
i am sure that the char
in unicode equal to 1576
so the question is
how could i print out the unicode decimal value of a char in a unicode text file ?