A problem about printf
来源:互联网 发布:淘宝店铺没有流量 编辑:程序博客网 时间:2024/04/26 18:56
Today I try to get the store mode of 'char' type.I write the code:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
FILE *fp=fopen("data","wb+");
int a[]={'a','A'};
char b[3];
if(fp==NULL){
printf("%s","error!");
exit(1);
}
fwrite(a,sizeof(int),2,fp);
rewind(fp);
fread(b,sizeof(char),2,fp);
fclose(fp);
printf("a[0]=%d,a[1]=%d,a=%s/n",&a[0],&a[1],a);
printf("b[0]=%d,b[1]=%d,b=%s/n",&b[0],&b[1],b);
system("PAUSE");
return 0;
}
I got the result:
a[0]=2293608.a[1]=2293612,a=a
b[0]=2293592,b[1]=2293593,b=a
While the file "data" is:
a[sapce][space][sapce][space]A
Why?
Then I read the code and find :
printf("a[0]=%d,a[1]=%d,a=%s/n",a[0],a[1],a);
printf("b[0]=%d,b[1]=%d,b=%s/n",&b[0],&b[1],b);
it not work,because the &a[0] return the address of a[0] not value of a[0].
Shame!
- A problem about printf
- A problem about Autoinvoice
- A problem about date
- A Problem about Polyline
- NYOJ219 a problem about data
- 南工219 A Problem About Date
- cf 320# A Problem about Polyline (二分)
- PKU 1020 A Problem about Tree LCA
- cf#320 Div.2 Problem C A Problem about Polyline
- cf#320 Div.2 Problem C A Problem about Polyline
- Codeforces Round #320 (Div. 1) A. A Problem about Polyline
- About GCC printf optimization
- Something about scanf&printf
- solved a problem about undefined / unresolved reference in c
- My first blog!! About a problem in SQL 2005 configuration...
- PKU Campus 2011 B A Problem about Tree lca倍增
- Codeforces Round #320 (Div. 2)C. A Problem about Polyline
- Codeforces Round #320 (Div. 2) C. A Problem about Polyline
- 生成pdf,使用itext
- 如何开启 Windows 2000 Server 上的远程桌面功能
- java打开pdf文档
- ASP.NET指令
- Sony VGN 笔记本声卡驱动安装问题
- A problem about printf
- 郁闷,不是我们这个阶段能用的词
- C#图片处理之: 另存为压缩质量可自己控制的JPEG
- 在web.config里配制连接Access数据库字符串
- 更新后滚动条还在原来编辑的记录处
- gcc常用参数详解
- 一个使用Neko提取HTML纯文本内容的程序例子
- 在remoting里使用客户端调用
- Delphi中使用API函数详解