Array of String

theortecical concept source:
http://stackoverflow.com/questions/20347170/char-array-and-char-array

code:

char *array = "One good thing about music";
char array[] = {"One", "good", "thing", "about", "music"};

Problem:
source: 101cproblems:

Problem 80: Array of String

Take an array of string named fruitNames and store four fruit names (“Mango”, “Jack-fruit”, “Banana”, “Litchi”). Now iterate the array using loop and print the names of the fruits each in a separate line.

code:

#include<stdio.h>
int main()
{
    int i;
    char *fruitNames[4]={"Mango","jack-fruit","Banana","Litchi"};
    char *(*str)[4]=&fruitNames;
    for(i=0;i<4;i++)
    {
        printf("%s\n",(*str)[i]);
    }

    return 0;
}

 

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

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