i couldn't run the program

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
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

float student_grade (float coursemark[18],float finalmark[18]);
char ID[18];
float coursemark[18],finalmark[18];

int main()

{
    char ID[18];
    float coursemark[18],finalmark[18];

    FILE *input;
    input=fopen("studentMark.txt","r");
    int i,j;
    for (i=0;i<18;i++)
    {
        fscanf(input,"%s %.2f %.2f",&ID[i],&coursemark[i],&finalmark[i]);

    }
    for (i=0;i<18;i++)
    {
        printf("%s\t%.2f\t%.2f\n",ID[i],coursemark[i],finalmark[i]);
    }
    fclose(input);
    return 0;
}


there's no error but some warnings on line 20 and 25...i just couldn't run it...need help asap.. thank you
here's the warning

line 20-unknown conversation type character '.' in format
line 20-too many arguments for format
line 25-format '%s' expects type 'char *', but argument 2 has type 'int'|
Last edited on
change line 20 to this:
fscanf(input,"%c %f %f",&ID[i],&coursemark[i],&finalmark[i]);

At the very least, remove the period as it doesn't have any place in that statement. Same thing goes for line 25: change %s to %c, change %.2f to %f

http://cplusplus.com/reference/cstdio/scanf/
Last edited on
Topic archived. No new replies allowed.