refresh
This commit is contained in:
parent
616f6f3f40
commit
941d60bd48
@ -1,6 +1,39 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#define LIST_SIZE 100
|
||||||
|
#define LINE_SIZE 101
|
||||||
|
|
||||||
|
struct pizza {
|
||||||
|
char name[101];
|
||||||
|
float price;
|
||||||
|
};
|
||||||
|
|
||||||
|
int read_pizza_list(struct pizza* list) {
|
||||||
|
int counter = 0;
|
||||||
|
char line[200];
|
||||||
|
for (int i=0; i < LIST_SIZE; i++) {
|
||||||
|
struct pizza item;
|
||||||
|
memset(&item,0,sizeof(struct pizza));
|
||||||
|
if (fgets(line, sizeof(line), stdin)==NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (sscanf(line, "%[^\n]", item.name) !=1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (fgets(line, sizeof(line), stdin)==NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (sscanf(line, "%f", &item.price) !=1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
memcpy(&listok[i], &item,sizeof(struct pizza));
|
||||||
|
counter +=1;
|
||||||
|
}
|
||||||
|
return counter;
|
||||||
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
printf("Hello world!\n");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user