Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <locale.h>
- #include <conio.h>
- #include <stdlib.h>
- #define ERROR_OPEN_FILE -3
- void read();
- int main ()
- {
- FILE *f;
- read();
- getch();
- return 0;
- }
- void read ()
- {
- FILE *f;
- char name[] = "array.txt";
- int len;
- f = fopen(name, "r");
- if (f == NULL) {
- printf("Error opening file");
- getch();
- }
- fscanf(f, "%d", &len);
- int array[len];
- int i = 0;
- printf("The inside of file (array x)");
- printf("\n%d\n", len);
- while (!feof(f))
- {
- int num;
- fscanf(f, "%d", &array[i]);
- printf("%d ", array[i]);
- i++;
- }
- fclose(f);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement