I need some help :))

Hi, guys. Im kinda new in programming and still find myself in trouble trying to make some codes work. ive been doing this one but i cant make the search option to work. could any of you please tell me where's the problem??? thanks

#include <stdio.h>
#include <string>
#include <iostream>
#include<new>
#include<stdlib.h>
using namespace std;

struct student{
string Surname;
string Initials;
string Group;
string operation;
string limits;
float Grades;};
int main(){
string Info;
int n,d,c,b,p=0;
cout<<" WELCOME TO THE DATABASE\n\n please enter the number of students to be added:\n";
cin>>n;
student*pointer=new student[n];

for(int i=0; i<n; i++)
{

student advance;
cout<<"\nEnter student's surname or END to terminate:\n";
cin>>pointer[i].Surname;
if (pointer[i].Surname=="END"){
break;

}
cout<<"Enter student's Initials:\n";
cin>>pointer[i].Initials;
cout<<"Enter student's Group:\n";
cin>>pointer[i].Group;
cout<<"Enter student's grade:\n";
cin>>pointer[i].Grades;
cout<<"\nStudent's surname:\n"<<pointer[i].Surname;
cout<<"\nStudent's Initials:\n"<<pointer[i].Initials;
cout<<"\nStudent's Group:\n"<<pointer[i].Group;
cout<<"\nStudent's Grades:\n"<<pointer[i].Grades;
system("cls");


cout<<"\nIf you want to add another student's data please enter CREATE or END to terminate program:\n";

cin>>pointer[i].Surname;
if(pointer[i].Surname=="CREATE"){
continue;}
else(pointer[i].Surname=="END");{
for(int i=0; i<n; i++);
{
cout<<"\nWould you like to perform a search? YES, NO:\n";
cin>>pointer[i].Surname;
if(pointer[i].Surname=="YES")system("cls");{
cout<<"\nSpecify the data to be searched:\n\n 1-for Surname search\n\n 2-for Initials search\n\n 3-for group search\n\n 4-for Grades search \n\n";
cin>>b;

switch(b){

case 1: cout<<"\nPlease enter the student's Surname to be searched:\n";
cin>>Info;
c=0;

for (i=0; i<n; i++) {if(p!=0){if(pointer[i].Surname==Info){

cout<<"\nStudent's surname:\n"<<pointer[i].Surname;
cout<<"\nStudent's Initials:\n"<<pointer[i].Initials;
cout<<"\nStudent's Group:\n"<<pointer[i].Group;
cout<<"\nStudent's Grades:\n"<<pointer[i].Grades;
c=c+2;}}}
break;

case 2: cout<<"\nPlease enter the student's Initials to be searched:\n";
cin>>Info;
c=0;
for (i=0; i<n; i++) {if(p!=0){if(pointer[i].Initials==Info){

cout<<"\nStudent's surname:\n"<<pointer[i].Surname;
cout<<"\nStudent's Initials:\n"<<pointer[i].Initials;
cout<<"\nStudent's Group:\n"<<pointer[i].Group;
cout<<"\nStudent's Grades:\n"<<pointer[i].Grades;
c=c+1;}}}
break;

case 3: cout<<"\nPlease enter the student's Group to be searched:\n";
cin>>Info;
c=0;
for (i=0; i<n; i++) {if(p!=0){if(pointer[i].Group==Info){

cout<<"\nStudent's surname:\n"<<pointer[i].Surname;
cout<<"\nStudent's Initials:\n"<<pointer[i].Initials;
cout<<"\nStudent's Group:\n"<<pointer[i].Group;
cout<<"\nStudent's Grades:\n"<<pointer[i].Grades;
c=c+1;}}}


}

}}}}


return 0;}


Last edited on
Topic archived. No new replies allowed.