Skip to content

Instantly share code, notes, and snippets.

@iwouldnot
Created October 17, 2017 14:05
Show Gist options
  • Save iwouldnot/4cb8c5c4c3e1ac91de525ddd7698a7f7 to your computer and use it in GitHub Desktop.
Save iwouldnot/4cb8c5c4c3e1ac91de525ddd7698a7f7 to your computer and use it in GitHub Desktop.
спешл фо даша
#include <stdio.h>
#include <stdlib.h> // For exit()
int main()
{
FILE* fptr;
char filename[100], c;
printf("Enter the filename to open \n");
scanf("%s", filename);
// Open file
fptr = fopen(filename, "r");
if (fptr == NULL) {
printf("Cannot open file \n");
exit(0);
}
scanf("%s", filename);
// Open file
fptr = fopen(filename, "r");
if (fptr == NULL) {
printf("Cannot open file \n");
exit(0);
}
// Read contents from file
c = fgetc(fptr);
while (c != EOF) {
printf("%c", c);
c = fgetc(fptr);
}
fclose(fptr);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment