diff --git a/cv1/Makefile b/cv1/Makefile new file mode 100644 index 0000000..f78f641 --- /dev/null +++ b/cv1/Makefile @@ -0,0 +1,11 @@ +# variables +CC=gcc +CFLAGS=-std=c11 -Wall -Werror +LDLIBS=-lm +OUTPUT=$@ + +# targets +%: %.c + $(CC) $(CFLAGS) $@.c $(LDLIBS) -o $(OUTPUT) + + diff --git a/cv1/program b/cv1/program index e7206f8..6753e90 100755 Binary files a/cv1/program and b/cv1/program differ diff --git a/cv1/program.c b/cv1/program.c index e606739..6a08465 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -5,10 +5,13 @@ #include #include +#define velkost strlen #define size 100 +void hacker_script(char *string, int len); + struct pizza { - char meno[size]; + char name[size]; float price; }; @@ -17,11 +20,67 @@ int main() { struct pizza listok[size]; char input[100]= {0}; char keyword[size] = {0}; - - printf("Zadaj hladanu surovinu:"); + char kopia[size] = {0}; + int pomocna[size] = {0}; + float cena = 0; + int counter = 0; + int helper = 2; + int yes = 0; + int y = 0; + char * pch; + + printf("Zadaj hladanu surovinu:\n"); fgets(keyword, sizeof(keyword), stdin); + keyword[velkost(keyword)-1] = '\0'; + hacker_script(keyword, strlen(keyword)); + printf("Zadaj jedalny listok:\n"); + while(fgets(input, sizeof(input), stdin) && strcmp( input, "\n" ) != 0 ){ + if(helper %2 == 0){ + strcpy(listok[counter].name, input); + yes++; + } + else{ + cena = strtof(input, NULL); + listok[counter].price = cena; + yes++; + } + if(yes == 2){ + counter++; + yes = 0; + } + helper++; + } - printf("%s", keyword); + for(int x=0; x