📝 Added sandbox (code sketchbook)
This commit is contained in:
parent
b475595f7f
commit
b5daf18b1a
142 changed files with 100702 additions and 0 deletions
24
sandbox/open2.c
Normal file
24
sandbox/open2.c
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main() {
|
||||
FILE * fptr;
|
||||
char c;
|
||||
|
||||
// Open file
|
||||
fptr = fopen("file.txt", "r");
|
||||
if (fptr == NULL) {
|
||||
printf("Cannot open file \n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// Read contents form file
|
||||
c = fgetc(fptr);
|
||||
while (c != EOF) {
|
||||
printf("%c", c);
|
||||
c = fgetc(fptr);
|
||||
}
|
||||
|
||||
fclose(fptr);
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue