Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- int main()
- {
- char ch, chr;
- FILE* fpw, *fpr;
- fpw = fopen("D:\\prgfiles\\data1.txt", "w");
- if (fpw == NULL)
- {
- printf("Error");
- exit(1);
- }
- printf("Enter any character: ");
- scanf("%c", &ch);
- fprintf(fpw, "%c", ch);
- fclose(fpw);
- if ((fpr = fopen("D:\\prgfiles\\data1.txt", "r")) == NULL)
- {
- printf("Error! opening file");
- return(1);
- }
- chr = getc(fpr);
- printf("This is the character entered by the user = %c \n", ch);
- printf("And this is the character read from the file = %c \n", chr);
- fclose(fpr);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement