I'm trying to create an array of pointers using my professors example in class. I can't seem to get it to work though.
char * ISBN[] = {
"1-214-02031-3",
"0-070-21604-5",
"2-14-241242-4",
"2-120-12311-x",
"0-534-95207-x",
"2-034-00312-2",
"1-013-10201-2",
"2-142-1223",
"3-001-0000a-4",
};
This is my professors example of declaring an array of pointers of type char. He says this is what we should do for the assignment. Sadly, I'm getting the error - Error (active) E0144 a value of type "const char *" cannot be used to initialize an entity of type "char *" -
I've asked about this before and someone said that char * has been deprecated. But the professor says that this is the declaration that we should use for the assignment. How would I go about trying to figure out how to get this array working? What exactly is this declaration doing?
const char *" and you should be fine.const. Your professor is likely teaching from a 20 year old syllabus. String Literals in C++ areconst char *in C (and older C++)char *was allowed (even though the string literal was immutable). No longer.autokeyword which changed behaviours about 10 years back or range-basedforwhich didn't exist. Not to mention if you don fall victim to that blackest of scourges Undefined Behaviour you stand a better chance of the instructor's compiler interpreting it the same way.const char *" - more accurately, they areconst char[N]which can decay intoconst char *