Created
May 31, 2020 09:57
-
-
Save 117503445/1b0ef3a79bb0a16c7c6175296370700a to your computer and use it in GitHub Desktop.
C : read and write UTF-8 file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* fgetwc example */ | |
#include <stdio.h> | |
#include <wchar.h> | |
int main() | |
{ | |
FILE *fin; | |
FILE *fout; | |
wint_t wc; | |
fin = fopen("in.txt", "r"); | |
fout = fopen("out.txt", "w"); | |
while ((wc = fgetwc(fin)) != WEOF) | |
{ | |
printf("%c",wc); | |
fputwc(wc,fout); | |
} | |
fclose(fin); | |
fclose(fout); | |
printf("File has been created...\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment