はじめまして。
Cで↓のような配列変数(文字)を作りたいのですが、どうすれば作れますか?
str[0][0] = "abc"
str[0][1] = "def"
str[0][2] = "ghi"
str[1][0] = "123"
str[1][1] = "456"
str[1][2] = "789"
ほんとに初歩的なこととは思いますが、どうかご教授ください。
配列変数の使い方
Re:配列変数の使い方
こういうことでしょうか。
#include <stdio.h> int main(void) { char *str[2][3] = {{"abc", "def", "ghi"}, {"123", "456", "789"}}; int i, j; for(i = 0; i < 2; i ++){ for(j = 0; j < 3; j ++){ printf("str[%d][%d] = \"%s\"\n", i, j, str[j]); } } return 0; }