-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path912.c
More file actions
51 lines (48 loc) · 1.02 KB
/
Copy path912.c
File metadata and controls
51 lines (48 loc) · 1.02 KB
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char vbuf[128];
char buf[128];
typedef struct{
char name[28+1];
int matrNr:16;
int belNote:3;
float klNote;
struct{
int jj,stGang,stgr;
}stGr;
}tStud;
void getStud(tStud pStud){
printf("Name von Student:\n");
fgets(buf,128,stdin);
buf[strlen(buf)-1]=0;
strcpy((*pStud).name,buf);
printf("Matrikel Nr.:\n");
fgets(buf,128,stdin);
(*pStud).matrNr=atoi(buf);
}
void putStud(tStud s){
printf("%-28s %d\n",s.name, s.matrNr);
}
tSud s,ps=NULL;
int anz=0;
char weiter='y';
int main(){
if(ps==NULL){
ps=malloc(sizeof(tStud));
if(ps==NULL) puts("malloc hat nicht geklappt\n");
else {tStud psx=realloc(ps, (anz+1)*sizeof(tStud));
if(psx) ps=psx;
else puts("nicht geklappt\n")exit(-1);}
}
// tStud* ps=malloc(sizeof(tSutd));
while(weiter=='y'){
s=getStud;
*ps=s;anz++;
for(i=0;i<anz;i++) putStud(ps+i);
printf("next y/n: ");
fgets(vbuf,128,stdin);weiter=vbuf[0];
}
free(ps);
return 0;
}