Friend I am new in c, I am trying to print string using in array of pointer I am following the code from online tutorial http://www.tutorialspoint.com/.my code link is Here's a link! all things are ok no error, when I run the the code message is shown: [Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings] there is no output, is the code in online is wrong, or what is fault can any one give me some idea my code is below:
#include <stdio.h>
const int MAX = 4;
int main ()
{
char *names[] = {
"Zara Ali",
"Hina Ali",
"Nuha Ali",
"Sara Ali",
};
int i = 0;
for ( i = 0; i < MAX; i++)
{
printf("Value of names[%d] = %s\n", i, names[i] );
}
return 0;
}
If any fault of me, I copying code, I am newer in c so I am learning from online tutorial, so please don't give any negative comment, if it also duplicate, kindly closed the question.
(sizeof names/sizeof *names)is the number of elements in array names. Alternatively / additionally, put the constant into the array definition too:char *names[MAX] = ...