-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.c
67 lines (61 loc) · 766 Bytes
/
example.c
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#change 7
#123456
#7891011
#11223344
#7777
#8888
#9999
#101010
#111111
#22
#3456
#7777
#9999
#333
#555
#xxx
#999
#111111
#1234
#4444
#5555
#6666
#7777
#8888
#9999
#aaaa
#bbbb
#cccc
#dddd
#eeee
#ffff
#gggg
#hhhh123
#1234
#6666
#7777
#include <stdio.h>
int main()
{
char name[50];
int marks, i, num;
printf("Enter number of students: ");
scanf("%d", &num);
FILE *fptr;
fptr = (fopen("C:\\student.txt", "w"));
if(fptr == NULL)
{
printf("Error!");
exit(1);
}
for(i = 0; i < num; ++i)
{
printf("For student%d\nEnter name: ", i+1);
scanf("%s", name);
printf("Enter marks: ");
scanf("%d", &marks);
fprintf(fptr,"\nName: %s \nMarks=%d \n", name, marks);
}
fclose(fptr);
return 0;
}