I have A problem in my C++ Code , I want to add 'n' number of Students with there Each Date , but I have an error when I Compare with if , here is my code
#include <iostream>
#include <stdio.h>
#include <string.h>
struct Address
{
char city[20];
char street[20];
};
struct University
{
char name1[20],name2[20],name3[20];
};
struct student
{
char name[20];
char degree[20];
University un;
Address add;
};
using namespace std;
int main (){
student st[20];
int n,i,j;
do{cin>>n;}while(n<=0 || n>20);
for(i=0;i<n;i++)
{
cout<<" Name Of student "<<i+1<<"\n";
cin>>st[i].name;
cout<<" Degree Of student "<<i+1<<"\n";
cin>>st[i].degree;
cout<<" University 1 \n";
cin>>st[i].un.name1;
cout<<" University 2 \n";
cin>>st[i].un.name2;
cout<<" University 3 \n";
cin>>st[i].un.name3;
cout<<" Enter The City Of student "<<i+1<<"\n";
cin>>st[i].add.city;
cout<<" Enter The Street Of student "<<i+1<<"\n";
cin>>st[i].add.street;
cout<<"\n* * * * * * * * * * * * * * * * * * * *\n";
}
for(i=0;i<n;i++)
if(st[i].degree == "phD")
cout<<st[i].name<<" is OK";
cout<<endl;
return 0;
}
So , I want To Check if the Student Has "phD" Then Output his name , But I get An Error , there is not output after the Date inputed , Why ? And When I change the date type of "degree" to string then I get Another Error in the if Say (is not a member of 'student').But I Really Want to do it With char , Can Help me please ?