diff --git a/cv1/program.c b/cv1/program.c index 914a534..15e98b3 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -5,6 +5,10 @@ bool check(char* s2, char *pz) { char *s=(char*) malloc(strlen(s2)+1); + if(s==NULL) + { + return false; + } char shifer[85]="oizeasbtbq"; for(int i = 0; s2[i]!='\0'; i++) @@ -38,19 +42,28 @@ int main() { printf("Zadaj␣jedalny␣listok:\n"); do - p=fgets(r, 299, stdin); - while(p!=NULL && p[0]=='\n'); - if(p==NULL) - break; - if(scanf("%f", &price)!=1) - break; - if(check(r, pizz)) { - count++; - printf("%s %.2f\n", r, price); - } + p=fgets(r, 299, stdin); + } + + while(p!=NULL && p[0]=='\n'); + { + if(p==NULL) + { + break; + } + if(scanf("%f", &price)!=1) + { + break; + } + if(check(r, pizz)) + { + count++; + printf("%s %.2f\n", r, price); + } + } } printf("Nacitanyh %d poloziek", count); return 0; -} +} \ No newline at end of file