Code:
#include <stdio.h>
#include<iostream>
int main()
{
FILE *fp, *fw;
wchar_t *buffer;
if((buffer=(wchar_t *)malloc(sizeof(wchar_t))) == NULL) /* It checks the buffer for the availability of space ,
to avoid the problem arise due to data overflow */
{
printf("Error: No enough memory\n");
getchar();
return 1;
}
else
{
fp = fopen("in2.txt","rb");
fw = fopen("output_untitled.txt","wb");
if ( fp == NULL || fw == NULL)
{
printf("Error: File cannot be opened\n");
getchar();
return 1;
}
else
{
while(fread(buffer,sizeof(wchar_t),1,fp) > 0)
fwrite(buffer,sizeof(wchar_t),1,fw);
}
}
getchar();
return 0;
}
Thanx in Advance