[Multidimensional Array]

0 Mark Julius Uy · December 27, 2014
Hi guys, could someone show me how to initialize an 2d array which is an alphanumeric 
For ex. "1A",2A".. etc.. thanks in advance

Post a Reply

Replies

Oldest  Newest  Rating
0 Laura Lee · January 3, 2015
Here you go,
#include <stdio.h>
#define STRING_COUNT 3
#define MAX_STRING_LENGTH 2
int main()
{
    int i = 0;
    char sz[STRING_COUNT][MAX_STRING_LENGTH] = {"1A","2B","3C"};
    char* p = 0;
    for(i = 0; i < STRING_COUNT; ++i)
    {
        int j = 0;
        p = sz;
        for(j = 0; j < MAX_STRING_LENGTH; ++j)
            printf("%c",*(p+j));
        printf("\n");
    }
    return 0;
}
  • 1

C

107,165 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator