I have a array declared as
我有一个数组声明为
char **a;
I am reading from a byte file, and saving the information in the array Here is the part where I have a question about
我正在读取一个字节文件,并将信息保存在数组中这是我有一个问题的部分
//Allocate memory is not shown here
fp = fopen(file, "rb");
for (i = 0; i < LN; i++){
for (j = 0; j < SN; j++)
bytesread = fread(&a[(int)i][(int)j], sizeof(char), 1, fp);
printf("%d \n", &a[(int)i][(int)j]);
}
When I print the value of the array each time, it does not give me the correct answer. When i change %d to %s is gives me an empty value.
当我每次打印数组的值时,它没有给出正确的答案。当我将%d更改为%s时,得到一个空值。
Can someone tell me why?
有人能告诉我为什么吗?
1 个解决方案
#1
4
You are printing the address of the item. Change your printf to
您正在打印项目的地址。改变你的printf,
printf("%d \n", a[(int)i][(int)j]);
#1
4
You are printing the address of the item. Change your printf to
您正在打印项目的地址。改变你的printf,
printf("%d \n", a[(int)i][(int)j]);