Initializacia

This commit is contained in:
Kozar 2024-10-02 18:56:18 +00:00
parent 8b64f9d216
commit fdb278d71d

View File

@ -36,25 +36,20 @@ void transform_to_hacker_script(const char *src, char *dest) {
int contains_normalized(const char *name, const char *search) { int contains_normalized(const char *name, const char *search) {
char transformed_name[LINESIZE], transformed_search[LINESIZE]; char transformed_name[LINESIZE], transformed_search[LINESIZE];
transform_to_hacker_script(name, transformed_name); transform_to_hacker_script(name, transformed_name);
transform_to_hacker_script(search, transformed_search); transform_to_hacker_script(search, transformed_search);
return strstr(transformed_name, transformed_search) != NULL; return strstr(transformed_name, transformed_search) != NULL;
} }
int read_pizza(struct pizza *item) { int read_pizza(struct pizza *item) {
char line[LINESIZE]; char line[LINESIZE];
if (!fgets(item->name, LINESIZE, stdin)) { if (!fgets(item->name, LINESIZE, stdin)) {
return 0; return 0;
} }
item->name[strcspn(item->name, "\n")] = '\0'; item->name[strcspn(item->name, "\n")] = '\0';
if (!fgets(line, LINESIZE, stdin)) { if (!fgets(line, LINESIZE, stdin)) {
return 0; return 0;
} }
item->price = strtof(line, NULL); item->price = strtof(line, NULL);
return 1; return 1;
} }
@ -66,7 +61,6 @@ int main() {
printf("Zadaj hladanu surovinu:\n"); printf("Zadaj hladanu surovinu:\n");
if (!fgets(search, LINESIZE, stdin)) { if (!fgets(search, LINESIZE, stdin)) {
printf("Error reading input.\n");
return 1; return 1;
} }
search[strcspn(search, "\n")] = '\0'; search[strcspn(search, "\n")] = '\0';
@ -89,6 +83,5 @@ int main() {
} }
printf("Nacitanych %d poloziek.\n", count); printf("Nacitanych %d poloziek.\n", count);
return 0; return 0;
} }