a

closed account (GETfizwU)
addd
Last edited on
So it is not your code, it is the code from the exercise?
make sure to put your program in code....
and i don't get the question that you are asking can you be more specific.




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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

// This program opens a file and reads a specified number of integers
// from it, but it isn't complete. Add the necessary code, using the
// comments as a guide. Run the program (with the appropriate 'make' 
// command), and compare your results with the data in the file
// referenced in the "prob6_test" target of the Makefile

// Your corrections will replace all the xxxxxxxx markers with real code.
// Hint: the number of x's is a clue;

// Set the number of integers to read from the file
#define NUMBER_PER_LINE 3

#include <stdio.h>
#include <stdlib.h> // For atoi()

int main(int argc, char* argv[])
{
// Part One of your task. Open the file named by the second command-line
// parameter; open the file in "read" mode.
FILE* inf = xxxxxxxxxxxxxxxxxxxx
if (!inf)
{
printf("Cannot open file %s\n", argv[1]);
return 1;
}

// Here are the integers it's trying to read, one per line
int n[NUMBER_PER_LINE];

fscanf(inf, "%d %d %d", &n[0], &n[1], &n[2]);

// Part Two of your task. You've read the date, now close the file
xxxxxxxxxxxx

// Part Three of your task; print out the integers you read above
// using an appropriate loop, one integer per line.

// print one integer in each line

for (int i = 1; i <= NUMBER_PER_LINE; i++)
{
xxxxxxxxxxxxxxxxxxxxx
}

return 0;
}



Topic archived. No new replies allowed.