正在加载图片...
9.1.1文件操作的C程序奥例 2.c程序实例2 ≈【例92】将用户从键盘输入的用户名和密码写到文件 userx中。 语程序文件名为92cp #include stdio. h" 程 #include<stdlib h> 序| struct userinfo /*定义结构体* i char username[10] char password[12] istu; void maino FILE*fp /*定义文件指针印* 60 fp=fopen ("user x","wb); /*以二进制方式打开文件 user X* if(fp-NULL) /*打开文件失败* 环 境 返回本节目录9.1.1 文件操作的C程序实例 《 C 语 言 程 序 设 计 》(Visual C++ .6 0 环 境 ) 返回本节目录 【例9.2】将用户从键盘输入的用户名和密码写到文件user.x中。 程序文件名为l9_2.cpp。 #include "stdio.h" #include <stdlib.h> struct userinfo /*定义结构体*/ { char username[10]; char password[12]; }stu; void main() { FILE *fp; /*定义文件指针fp*/ fp=fopen("user.x","wb"); /*以二进制方式打开文件user.x*/ if(fp==NULL) /*打开文件失败*/ 2.C程序实例2
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有