[英]Initialize a 2D string array and print it
I'm learning C for fun and I'm trying to make a program that creates a array of strings. 我正在学习C的乐趣,并且正在尝试制作一个创建字符串数组的程序。 I'm trying this right now:
我现在正在尝试:
char str[2][10];
strcpy(str[0], "foo");
strcpy(str[1], "bar");
printf("%d \n",str[0]);
printf("%d \n",str[1]);
But my printf
returns only some numbers, and I would like it to display foo and bar . 但是我的
printf
只返回一些数字,我希望它显示foo和bar 。 I've been reading about and I think that it is displaying a pointer to my strings. 我一直在阅读,我认为它正在显示指向我的字符串的指针。 What am I doing wrong?
我究竟做错了什么?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.