Hello, I have recently started to learn from a book, and I am currently copying one of the examples from the book. But it doesnt seem to be working and I do not understand why. I have pasted the code below, the error is coming from this part :
The error I am getting says that "a value of type "const char *" cannot be used to initialize an entity of type char * ". I understand that a constant pointer is one which cannot change the address which it stores. But I am not creating that. Or is that what is created to point at this string table the book is talking about? And if that is the case then what is the problem? If anyone could help, it would be appreciated.
and most compilers will tolerate it if you tell it to use less strict rules, but i don't advise it. Instead, get a newer example / book. Prefer one that uses <string>, not char array or char *.
using arrays will make it shut up about it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
int main()
{
//---------max of 10 words, max 100 length each
char words[10][100] = {
"pencil" , "A writing instrument",
"keyboard" , "An input device",
"", ""
};
for(int i = 0; i < 5; i++)
cout << words [i] << endl;
}