Answers for "array of strings c"

C
1

array of strings in c

char ch_arr[3][10] = {
                         {'s', 'p', 'i', 'k', 'e', '\0'},
                         {'t', 'o', 'm','\0'},
                         {'j', 'e', 'r', 'r', 'y','\0'}
                     };
Posted by: Guest on April-06-2021
0

create array of strings in c from user input

#include <stdio.h>

int main()
{
   char str[5][10];

   printf("enter the strings...\n");
   for(int i =0; i < 5; i++)
   scanf("%s", str[i]);

   printf("All strings are...\n");
   for(int j =0; j < 5; j++)
   printf("%s\n", str[j]);
}
Posted by: Guest on April-29-2021
-1

matrix of string in c

#define ROW 3
#define COL 3
int main(int argc, char *argv[])
{
    int i, j;
    char *matrix[ROW][COL] = {
        {"aa", "bb", "cc"},
        {"dd", "ee", "ff"},
        {"gg", "hh", "ii"},
    };

    for(i = 0; i < ROW; i++){
        for(j = 0; j < COL; j++){
            printf("matrix[%d][%d] is %s\n", i, j, matrix[i][j]);
        }
    }

    return 0;
}
Posted by: Guest on January-15-2021

Code answers related to "C"

Browse Popular Code Answers by Language