invalid conversion from `char' to `const char*
I'm writing a programm in C++ that mimics a database, and this problem keeps comming up, and I can't seem to get rid of it. I placed a comment above the line where the problem is. And sorry its so long!
Code:
#include <iostream> |
studentname is a char, strcmp expects char*, so give it the address of student name.
Code:
while (strcmp(score, &(The_Scores[i].student_name) )!=0 && i <=num_students) |
Thanks a million leonscape!!
One of these days I'll go from trying to learn C++ to kinda knowing C++ Thanks again! |
My advice, would be not to use char*, but use the string class from the STL. This would cure most of your problems. you've included the header why not use it?
if ( score != The_Scores[i].student_name && i <=num_students ) |
Could you explain it a little more, I don't quite understand what you meen.
I'm still very new to programming, and trying to get an understanding of it all. |
char is a single character, ( as in studentname ) char* is a pointer to a char. arrays of chars are used for strings. a char array without an index is also a char*.
string is a c++ class. Its very useful, as unlike a char array, its dynamically sized ( no need to worry so much about its length. ) and can beused with operators. eg. Code:
string str2; |
Ok I get it, thanks again leonscape!
|
All times are GMT -5. The time now is 01:44 AM. |