diff --git a/cv1/program.c b/cv1/program.c index 28c269f..63a1101 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -10,11 +10,11 @@ struct pizza { float prize; char name[LINESIZE]; }; +void trim(char* str); int search_string(const char* heap, const char* needle); int read_pizza(struct pizza* item); char hacker_script(char c); int main(){ - struct pizza jedalny_listok[POCET_JEDAL]; memset(jedalny_listok, 0,sizeof(struct pizza)*POCET_JEDAL); int counter; @@ -22,48 +22,62 @@ int main(){ memset(line,0,LINE_SIZE); printf("Zadaj hladanu surovinu:\n"); char* r = fgets(line,LINE_SIZE,stdin); + trim(line); if(r != NULL && line[1] != 0){ printf("Zadaj jedalny listok\n"); struct pizza item; - counter = 1; + counter=0; while(read_pizza(&item)){ - strcpy(jedalny_listok[counter-1].name, item.name); - jedalny_listok[counter-1].prize=item.prize; + strcpy(jedalny_listok[counter].name, item.name); + jedalny_listok[counter].prize=item.prize; + //printf("%s",jedalny_listok[counter].name); + //printf("%s",item.name); counter += 1; } } + //printf("%d\n",counter); for(int i=0;i