cethint cethint - 24 days ago 6
C Question

How to declare string array in c

#include<stdio.h>

int main()
{
int i;
string A[]={"Ahmet", "Mehmet", "Bulent", "Fuat"};

for(i=0;i<=3;i++){
printf("%s",A[i]);
}
return 0;
}


How can i see my array's elements as output?

Compiler says "'string' undeclared".

Answer

This way:

 char *A[] = {"Ahmet", "Mehmet", "Bülent", "Fuat"};

A is an array of pointers to char.