Hello there.
I am a beginner (very beginner) into C programming.
I am trying to take numbers from a .txt and put them into an array to organize them with Shellsort. I also have the problem that there are more than one vector in my .txt, and the first number represents its size, for example:
6 44 56 25 51 11 13 (6 is not a part of it, it only means it has 6 numbers)
4 23 51 6 31 (4 is not a part of it)
But I am having problems trying to fullfill my arrays. Here is what I have (without the Shellsort function, its working nice):
Code:
int main() {
FILE *textfile;
char ch;
int j, i;
textfile = fopen("readme.txt", "r");
if(textfile == NULL)
return 1;
fscanf(textfile, "%d", &j);
int arr[j];
while((ch = fgetc(textfile))!=EOF) {
for (i = 1; i < j; i++){
arr[i] = ch;
}
}
fclose(textfile);
return 0;
}