can any1 help me with this error
[C++ Error] project2.cpp(258): E2034 Cannot convert 'char *' to 'char'
cheers
can any1 help me with this error
[C++ Error] project2.cpp(258): E2034 Cannot convert 'char *' to 'char'
cheers
Looks like it should be in the c++ board for a start.[C++ Error] project2.cpp(258): E2034 Cannot convert 'char *' to 'char'
Cannot convert a pointer to char to char.
Show us the line with the error.
All spelling mistakes, syntatical errors and stupid comments are intentional.
test=records[i].surname ;
where test is declared as a char
and records is the array
and i am doin C not C++
thnx
Then don't use a ".CPP" file. Use a ".c" file. Post what 'test' is and what the structure looks like.test=records[i].surname ;
where test is declared as a char
and records is the array
and i am doin C not C++
thnx
Quzah.
Hope is the first step on the road to disappointment.
>test=records[i].surname ;
If test is of type char and surname of type char *, then the error will occur.
To make things sure, show us the type of variable records.
struct student
{
char surname[40];
int mark1;
int late1;
int mark2;
int late2;
int mark3;
int late3;
char grade[1];
};
struct student records[MAX];
there is the structure of the array
and test is declared as
char test[20];
thnx
So surname is of type char and 40 chars long and test is of type char and 20 chars long. That's not correct to assign them to eachother.
You could solve this by using strncpy.
#include <string.h>
char *strncpy(char * restrict s1, const char * restrict s2, size_t n);
In your case you could do:
strncpy (test, records[i].surname, 20);
cheers mate