Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Programming Languages
C, C++ and C#
Read from a file into an array?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="fmsguy06, post: 3672720, member: 52366"] I changed one line fscanf(fp, "%d", &x[s]); so now: int main(int argc, char *argv[]) { int numberOfChar; FILE *fp; fp=fopen("test.txt", "rb"); if (fscanf(fp, "%d", &numberOfChar) == 1) printf("%d\n", numberOfChar); int x[numberOfChar]; int s; for (s = 0; s < numberOfChar; s++) { fscanf(fp, "%d", &x[s]); } return 0; } It returns the number 3... which is the first number of the text document...so I think I'm heading in the right direction, but still not entering the data into the array?[/s][/s] [/QUOTE]
Verification
Post reply
Forums
Programming Languages
C, C++ and C#
Read from a file into an array?
Top