我正在尝试在 C 中打印一个字符数组,但我无法打印所有内容。我想打印:b1 b2 我的代码:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
char def[3][10]; //define a multidimensional array of characters
strcpy(def[0],"b1"); //insert "b1" at first line
strcpy(def[1],"b2"); //insert "b2" at first line
printf("%s",def); //print everything?
}
上面的代码只打印b1
. 我已经尝试过:
printf("%s",def[0]);
printf("%s",def[1]);
但我有错误“无效使用未指定边界的数组”