this is the error on compilingCode:#include <stdio.h> #include <stdlib.h> void menu(); // struct containing recipe typedef struct { char recipeName[40]; char recipeHowTo[1000]; int howManyPerson; int level; int timeToEat; } recipe; // struct for list struct element { recipe data; struct element *elemPtr; }; // prototypes void menu(int choice, struct element *listPtr); struct element *insertRecipe(struct element *listPtr); void listRecipes(struct element *listPtr); int main() { int choice; struct element *list = NULL; menu(choice,list); system("PAUSE"); return 0; } void menu(int choice, struct element *listPtr){ printf("----Recipes for fun\n"); printf(".1 Search Recipe"); printf(".2 View Recipes"); printf(".3 Insert Recipe"); printf(".4 Edit Recipe"); printf(".5 Delete Recipe"); printf(".8 Set measure system"); printf(".9 Email Recipes"); printf("Insert the number corrispondant to what you need and press ENTER! "); scanf("%d",choice); if ( choice == 1 ) { } else if ( choice == 2 ) { listRecipes(listPtr); } else if ( choice == 3 ) { listPtr = insertRecipe(listPtr); } else if ( choice == 4 ) { } else if ( choice == 5 ) { } else if ( choice == 8 ) { } else if ( choice == 9 ) { } else { } } // INSERT RECIPE struct element *insertRecipe(struct element *listPtr){ //var declairation char recipeName[40]; char recipeHowTo[1000]; int howManyPerson; int level; int timeToEat; recipe x; struct element *xPtr; //filling info printf("Insert the Recipe name:\n"); scanf("%s\n",recipeName); strcopy(x.recipeName,recipeName); printf("Insert the how to:\n"); scanf("%s\n",recipeHowTo); strcopy(x.recipeHowTo,recipeHowTo); printf("Insert for how many person is the recipe"); scanf("%d\n",howManyPerson); x.howManyPerson = howManyPerson; printf("Insert the level of the recipe from 1 to 5"); scanf("%d\n",level); x.level = level; printf("Insert the time needed to prepare the recipe"); scanf("%d\n",timeToEat); x.timeToEat = timeToEat; if (*listPtr != NULL) { xPtr = (struct element *)malloc(sizeof(struct element)); //allocate mem xPtr->data = x; //put x in data of the pointer xPtr->elemPtr = listPtr; //put xptr on top list } else { listPtr = (struct element *)malloc(sizeof(struct element)); listPtr->data = x; listPtr->elemPtr = NULL; //listPtr points to end list listPtr->xPtr; } return(listPtr); } //LIST RECIPES void listRecipes(struct element *listPtr){ if ( listPtr == NULL ) { printf("No recipes in the database"); } else { while ( listPtr != NULL ) { printf("%s\n",listPtr->data.recipeName); listPtr = listPtr->elemPtr; } } }
gcc.exe -c MainRecipe.c -o Objects/MingW/MainRecipe.o -I"C:/Program Files/Dev-Cpp/Include"
MainRecipe.c: In function `insertRecipe':
MainRecipe.c:88: error: invalid operands to binary !=
MainRecipe.c:97: error: structure has no member named `xPtr'
cant understand what is wrong



LinkBack URL
About LinkBacks




D