【文档说明】C语言工程设计03_输入输出.pptx,共(30)页,2.303 MB,由精品优选上传
转载请保留链接:https://www.ichengzhen.cn/view-290368.html
以下为本文档部分文字说明:
C语言工程设计杨志钢zgyang@hrbeu.edu.cn数据输入输出标准输出printf标准输出printf标准输出printf标准输出printf标准输出sprintf标准输入scanf标准输入scanf标准输入scan
fD标准输入scanf字符的输入输出字符串的输入输出scanf(“%s”,…)不接收空格、制表符而gets能够接收空格、制表符文件的输入输出文件的输入输出文件的输入输出文件的输入输出文件的输入输出#include<stdio.h>voidmain(){FILE*fp=
fopen("E:\\tmp.txt","r");charch;ch=fgetc(fp);while(ch!=EOF){putchar(ch);ch=fgetc(fp);}}文件的输入输出文件的输入输出文件的输入输出文件的输入输出文件
的输入输出文件的输入输出文件的输入输出文件的输入输出文件的输入输出练习:读取BMP文件信息图像文件头(0x00-0x0D,共14Bytes)typedefstructbmpfileheader_t{unsignedshortbfType;/
*文件类型‘BM’=0x4D42*/unsignedintbfSize;/*文件大小,字节为单位*/unsignedshortbfRes1;/*保留,必须设置为0*/unsignedshortbfRes2;/*保留,必须设置为0*/
unsignedintbfOffBits;/*从文件头开始到实际的图象数据之间的字节的偏移量*/}bmpfileheader_t;练习:读取BMP文件头信息位图信息头(0x0E-0x35,共40Bytes)typedefstructbmpinfoheader_t{unsignedintb
iSize;/*bmpinfoheader_t结构所需要的字数*/unsignedintbiWidth;/*图象的宽度,以象素为单位*/unsignedintbiHeight;/*图象的高度,以象素为单位*/unsigne
dshortbiPlanes;/*位图的位面数,该值总是1*/unsignedshortbiBitCount;/*每个像素的位数,1(单色),4(16色),8(256色),16(64K色,高彩色),24(1
6M色,真彩色),32(4096M色,增强型真彩色)*/unsignedintbiCompression;/*压缩说明,0(不压缩),1,2,3*/unsignedintbiSizeImage;/*图象的大小,以字节为单位,数值上等于(≥位图宽度的最小的4的倍数)×位图高度×每个像素位数*/un
signedintbiXPelsPerMeter;/*水平分辨率,用象素/米表示*/unsignedintbiYPelsPerMeter;/*垂直分辨率,用象素/米表示*/unsignedintbiClrUsed;/*位图使用
的颜色索引,(0:使用所有调色板项)*/unsignedintbiClrImportant;/*对图象显示有重要影响的颜色索引数目,(0:表示都重要)*/}bmpinfoheader_t;练习:读取BMP文件头信息1.编写程序,读取BMP图像文件头信息,并打
印显示2.对于biBitCount=8的BMP图像,生成其反色图像。