zizi110
Member level 1
- Joined
- Jun 24, 2013
- Messages
- 41
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 6
- Activity points
- 313
hi all,
i want to read a text file in keil.
i found this code on net but it dosnt work in keil!!!
i test it in GCC compiler and it works! but i dont know why it dose not work in keil...
thanks
code:
i want to read a text file in keil.
i found this code on net but it dosnt work in keil!!!
i test it in GCC compiler and it works! but i dont know why it dose not work in keil...
thanks
code:
Code dot - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 #include <stdio.h> #include <stdlib.h> int txt2array(char *file_name) { FILE *myFile; myFile = fopen(file_name, "r"); //read file into array int N=499998; int numberArray[N]; int i; if (myFile == NULL) { printf("Error Reading File\n"); exit (0); } for (i = 0; i < N; i++) { fscanf(myFile, "%1d,", &numberArray[i] ); } for (i = 0; i < N; i++) { printf("Number is: %1d\n\n", numberArray[i]); } fclose(myFile); return numberArray; }
Last edited by a moderator: