Horje
array of strings in c Code Example
array of strings in c
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

#define MAX_LENGTH 100
#define NUM_STRINGS 10

int main(){
    char *arr3[NUM_STRINGS] = { "first string",
                                "second string",
                                "third string",
                                "fourth string",
                                "fifth string" };
    char* str1 = "string literal";
    arr3[8] = str1;
    arr3[9] = "hello there";

    for (int i = 0; i < NUM_STRINGS; ++i) {
        printf("%s, ", arr3[i]);
    }
    printf("\n");

    exit(EXIT_SUCCESS);
}
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]);
}
c array of strings
char commands[][4] = {
        "add",
        "prn",
        "lea",
        "inc",
        "mov"
};
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;
}




C

Related
c copy 2 strings\ Code Example c copy 2 strings\ Code Example
linux play youtube audio only Code Example linux play youtube audio only Code Example
FIRST PROGRAM IN C Code Example FIRST PROGRAM IN C Code Example
c program hide console window Code Example c program hide console window Code Example
yterm urllib.error.HTTPError: HTTP Error 404: Not Found Code Example yterm urllib.error.HTTPError: HTTP Error 404: Not Found Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
12