How to declare string array in c

Viewed 50673
#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".

4 Answers

you can use cs50 library to work with string or you can work with pointers.

CS50

string names[] = {"Mohammed", "Mhammed", "Ali", "Lora"};

pointer

char *names[] = {"Mohammed", "Mhammed", "Ali", "Lora"};
Related