C - Write program to Output each character in array of string using pointer and putchar() function.

Requirements

Write program to Output each character in array of string using pointer and putchar() function.

Hint

Use outer for loop to iterate each string.

Demo

#include <stdio.h>

int main()// w  ww  .  j  a va  2  s.c  o  m
{
    char *fruit[] = {
        "watermelon",
        "banana",
        "pear",
        "apple",
        "coconut",
        "grape",
        "blueberry"
    };
    int x,a;

    for(x=0;x<7;x++)
    {
        a=0;
        while(putchar(*(*(fruit+x)+a++)))
            ;
        putchar('\n');
    }

    return(0);
}

Result

Related Exercise