0
Help! I Need to read an array of numbers from a txt file with C!
Hi I have an array of numbers with many lines (actually not knowing how many) in a text file. Each line contains 6 numbers. I have to slice/cut in pairs over each line containing the six numbers to apply a function which takes as arguments three vectors with dimension two, then printing the results for each line with the position of each line. I am not sure how to face this problem I can print the whole array but not sure what is the best way to do what I want to do (to pass the data as function's arguments). I am quite new at this language. Should I use fgets?Thanks in advance and sorry for my English!
4 Respuestas
0
So your text file has example
1 2 3 3 5 6
2 3 4 5 6 7
And you want to make arrays like
int number[3]]2] = {1, 2, 3, 4, 5, 6}
Which would be like
1 2
3 4
5, 6
So on and so forth?
0
Mm something like
V1[2]={1 2}
V2[2]={3 3}
V3[2]={3 5}
Use v1 v2 y v3 as arguments for my function then print the solutions and then save again the next values in v1 v2 and v3. Compute and print. I need to print for each line the function for each three pairs of numbers.
0
Here are some helpful suggestions to opening and reading the text.
https://stackoverflow.com/questions/3463426/in-c-how-should-i-read-a-text-file-and-print-all-strings
Then parse the string into arrays you need.
0
Thanks!!! :)