My program needs these features:
NOTE. I did not include codes for numbers 1,2 and 4, since I already finished them. The third is my problem.
- The program must constantly allow user input if the user still wants to. (Dynamically)
- Get the final student class (average for frst_grade, scnd_grade, fnl_grade)
- Get the number of college students.
- Get the student name by entering s_id.
My problem is how to compare the search input with the user input in s_college to get the number of students. The only way I know is to use strcmp (), but it gives me this error: invalid conversion from 'char' to 'const char *' [-fpermissive]
So, how do I compare these two to get the number of college students?
#include<stdio.h> #include<string.h> #include<conio.h> int i,n,sum,search,num=0,ctr=0; char answer,choice,choice2,search2; struct record{ int s_id; char s_name[100]; char s_course; char s_college[5]; int s_scoress; }id[100],name[100],course,college[100],scores; struct s_scores{ int frst_grade; int scnd_grade; int fnl_grade; }first,second,final; void ADD(); void COLLEGE(); void ID(); void COLLEGE(){ printf("Enter college (abbreviation only)"); scanf("%s",&search2); for(i=0;i<num;i++){ if(strcmp(college[i].s_college,search2)==0); ctr++; } printf("The number of students in %s is %d",search2,ctr);
source share