-
testing for blank line
How do I test for a blank student name
ie if ((pa+i)->fullname==blank line)
break;
Code:
int getinfo(student pa[], int n)
{
int i;
for (i=0;i<n;i++)
{
cout << "Enter the name of student "<< i+1 <<":";
cin.getline((pa+i)->fullname,SLEN);
if ((pa+i)->fullname=='\0')
break;
cout << "Enter student "<<i+1<< " hobby:";
cin.getline((pa+i)->hobby,SLEN);
cout << "Enter student "<< i+1<< " ooplevel:";
cin >>(pa+i)->ooplevel;
cin.get();
}
return i;
}
-
Well Why dont you just get the length of the name and if its 0 then it was a blank line.
-
test for blank name
is there a function to determine the length?
can't find one in this book
-
strlen() does that.
I think its included in <string.h>