[SOLVED] How to declare string array in c

Issue

#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”.

Solution

This way:

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

A is an array of pointers to char.

Answered By – ouah

Answer Checked By – Senaida (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *