Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- int ch;
- FILE *fp;
- char fname[50]; //for holding file name
- printf("Enter file name:");
- scanf("%s",fname); //full path, i did c:\kino1\abc2.txt
- fp = fopen(fname, "r"); //open file for reading
- if (fp == NULL) //not sucessfull
- {
- printf("Cant open file. Program ended\n");
- exit(1); //exit programm
- }
- //getc(fp) gets char from open file
- while((ch = getc(fp)) != EOF)
- putchar(ch);
- fclose(fp); //file closed
- return 0;
- }
Add Comment
Please, Sign In to add comment