【发布时间】:2017-11-21 18:33:40
【问题描述】:
我正在尝试从C 制作一个简单的程序来存储数据,然后将其保存到2d array,二维数组中存储了 2 个数据。我认为保存代码运行良好,但是当我尝试打印存储在二维数组中的数据时,它崩溃了。
这是我的代码:
#include <stdio.h>
int main(){
char data[2][3];
//input the data then save it in 2d array
printf("enter the first word: ");
scanf("%s", &data[0][0]);
printf("enter the second word: ");
scanf("%s", &data[1][0]);
//here is the problem when iam trying to print out the stored data in 2d array
printf("first word: %s\nsecond word: %s", data[0][0],data[1][0]);
}
【问题讨论】:
-
你使用了什么输入法?
-
我的意思是有类似的数据库,所以会有账单、姓名、地址、电话存储在二维数组中,我想将字符串存储在二维数组中,然后我会打印出来