I am trying to implement an array of strings using pointer. Following is my code.
#include <stdio.h>
const int MAX = 4;
int main () {
char *names[] = {
"abcd",
"efgh",
"ijkl",
"mnop",
};
int i = 0;
for ( i = 0; i < MAX; i++) {
printf("Value of names[%d] = %s\n", i, names[i] );
}
return 0;
}
I am having a warning at the time of running it. Following is the warning:
C:\workspace>g++ test_pointer_string_arr.c -o tpsa.exe
test_pointer_string_arr.c: In function 'int main()':
test_pointer_string_arr.c:12:4: warning: deprecated conversion from string const
ant to 'char*' [-Wwrite-strings]
};
^
test_pointer_string_arr.c:12:4: warning: deprecated conversion from string const
ant to 'char*' [-Wwrite-strings]
test_pointer_string_arr.c:12:4: warning: deprecated conversion from string const
ant to 'char*' [-Wwrite-strings]
test_pointer_string_arr.c:12:4: warning: deprecated conversion from string const
ant to 'char*' [-Wwrite-strings]
what is the problem?