Quote:
>Hi
>I need some help .....Iam new at programming. How do you put the contents of a
>file into a one dimensional parallel array???
>scanf ("%d%d", acct_num,over_due); ??????
If acct_num and over_due are ordinary variables then the above line will
not work as scanf requires the addresses of such variables, so:
scanf("%d %d", &acct_num, %over_due);
If you are filling an array then you can do the following:
scanf("%d %d", acct_num[i], over_due[i]);
Where i is a loop index declared elsewhere.
Quote:
>in the file there are two sets of numbers. I have to load them into two
>separate arrays....and i have no idea how???? Any help would be appreciated.
Sounds like homework so here is a hint rather than a solution.
I am assuming that the format of your file is something like:
<number> <separator> <number> <end of line>
<number> <separator> <number> <end of line>
........
Where <separator> is something like a space or a comma.
The following pseudo-code shows most of what to do.
DECLARE your arrays and other variables.
OPEN the file for reading.
FOR each line in the file
READ a line from the file (use fgets)
PUT the numbers into the array (use sscanf, similar to scanf)
END FOR
CLOSE the file.
PRINT the contents of the arrays (or whatever).
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Bob Wightman
--