Wednesday 20 December 2017

c++ - Why can't I assign an array variable directly to another array variable with the '=' operator?

Why does the following assignment not work? I would like a
low-level explanation if possible. Also, here's the compiler error I get: incompatible
types in assignment of 'char*' to 'char
[20]'



class UCSDStudent
{

char name[20];


public:

UCSDStudent( char name[] ) {


//this-> name = name; does not work! Please explain why not
strcopy( this
-> copy, copy ); //works

}

};

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...