+ 1

error: 'count' was not declared in this scope & error: 'Pals' was not declared in this scope

I try to make a program like the one in this book and write it the same #include <stdio.h> #include <conio.h> #include <stdlib.h> #include <string.h> int count; int Pals; int search() { char querystring[50]; int choice; int d,m,y; int i=-1; printf("1. Search by name"); printf("2. Search by phone"); printf("3. Search by email"); printf("4. Search by birthdate"); printf("Enter you choice [1-4] :"); scanf("%d",&choice); switch(choice) { case 1:printf("Enter name to search :"); fflush(stdin); gets(querystring); for(i=0;i<count;i++) if(strcmpi(Pals[i].name,querystring)==0) break; break; case 2:printf("Enter phone to search :"); fflush(stdin); gets(querystring); for(i=0;i<count;i++) if(strcmpi(Pals[i].phone,querystring)==0) break; break; case 3:printf("Enter email to search :"); fflush(stdin); gets(querystring); for(i=0;i<count;i++) if(strcmpi(Pals[i].email,querystring)==0) break; break; case 4:printf("Enter birthdate to search :"); scanf("%d%d%d",&d,&m,&y); for(i=0;i<count;i++) if(Pals[i].bday.day == d && Pals[i].bday.month == m && Pals[i].bday.year == y) break; break; } return i; }

6th Sep 2021, 8:03 AM
Muhammad Giovani
Muhammad Giovani - avatar
9 Answers
+ 5
You should declare the variable count and Pals(array) in the beginning of your code, in the function search, like the other variables.
6th Sep 2021, 8:06 AM
Dimitris N. Kapoulas
Dimitris N. Kapoulas - avatar
+ 4
The problem is:Pals. Did you declare the variable Pals like array;
6th Sep 2021, 8:16 AM
Dimitris N. Kapoulas
Dimitris N. Kapoulas - avatar
+ 4
What is the Pals; Is it a number, a character, an array? You use it to the if in every case.
6th Sep 2021, 8:26 AM
Dimitris N. Kapoulas
Dimitris N. Kapoulas - avatar
+ 4
Ok, maybe you should look closely the book you have. I can't see it. Maybe is something else.
6th Sep 2021, 8:33 AM
Dimitris N. Kapoulas
Dimitris N. Kapoulas - avatar
+ 4
I think that the best is to search and understand by yourself and not get the answer by me.
6th Sep 2021, 8:37 AM
Dimitris N. Kapoulas
Dimitris N. Kapoulas - avatar
+ 2
Sorry in advance, I don't understand what should I do to make the program run?
6th Sep 2021, 8:21 AM
Muhammad Giovani
Muhammad Giovani - avatar
+ 2
what I see and I understand a little bit, the use of each case is to input a name, mobile number, email, and birthday to find out if there is any
6th Sep 2021, 8:28 AM
Muhammad Giovani
Muhammad Giovani - avatar
+ 1
now error: subscripted value is neither array nor pointer nor vector on this line if(strcmpi(Pals[i].name,querystring)==0)
6th Sep 2021, 8:14 AM
Muhammad Giovani
Muhammad Giovani - avatar
+ 1
may I give the book for you to see? I'm very grateful for the help
6th Sep 2021, 8:35 AM
Muhammad Giovani
Muhammad Giovani - avatar