当前位置:三九宝宝网 → 宝宝教育 → 教学论文 → 正文

C语言文件输入输出问题

更新:01-07 整理:39baobao.com
字体:

[C语言清屏指令检错没有错误但是输入!无反应如何更改可以清]在csdn论坛里看到这样一个问题:如何在c语言命令提示下清除屏幕? 感兴趣,随查之。 有解: #include<stdio.h> #include<dos.h> void main() { int i; scanf("%d",&i); system("cls"); /...+阅读

#include

#include

#include

#define max 20

struct person

{

char name[max];

char password[max];

char city[max];

}yonghu;

int LogIn()

{

int i=0;

char name[max],password[max];

FILE *fp;

if((fp=fopen("person.dat","rb"))==NULL)

{

printf("\ncan not open file");

exit(0);

}

fread(&yonghu,sizeof(struct person),1,fp);

printf("\nplease put your name: ");

scanf("%s",name);

printf("\nplease put your password: ");

while((i>=0)&((password[i++]=getch())!=13))

{

if(password[i-1]=='\b')

{

printf("%c%c%c",'\b','\0','\b');

i=i-2;

}

else

printf("*");

}

password[--i]='\0';

if(!strcmp(name,yonghu.name)&!strcmp(password,yonghu.password))

{

printf("\nsuccess");

return 1;

}

else

{

printf("\nerror");

return 0;

}

}

void Register()

{

char *p="person.dat";

FILE *fp;

printf("\nplease enter your usename: ");

scanf("%s\n",yonghu.name);

printf("please enter your password: ");

scanf("%s\n",yonghu.password);

printf("please enter your city: ");

scanf("%s\n",yonghu.city);

if((fp=fopen("person.dat","wb"))==NULL)

{

printf("\nOpen file %s error!",p);

system("pause");

exit(0);

}

if(fwrite(&yonghu,sizeof(struct person),1,fp)!=1)

printf("\nfile write error");

fclose(fp);

}

void Go()

{

printf("1.Log In\n");

printf("2.Register\n");

printf("3.Log Out\n");

printf("please choose: ");

switch(getch())

{

case '1':LogIn();break;

case '2':Register();Go();break;

case '3':exit(0);break;

default: printf("\nerror!\n");Go();break;

}

}

void main()

{

Go();

}

本文地址:https://www.39baobao.com/show/29_26797.html

以上内容来自互联网,请自行判断内容的正确性。若本站收录的信息无意侵犯了贵司版权,请联系我们,我们会及时处理和回复,谢谢.

以下为关联文档:

用c语言求阶乘50!的具体数值及其位数并输出结果尽管已有推荐答案,觉得还是为你提供一个代码参考为好。这段代码可以输入系统允许长度的十进制整数,然后输出它的阶乘的位数和阶乘值!你可以在VC++6.0中试试…… #include "stdio...

易语言输入法注入怎么搞版本 2 .子程序 __启动窗口_创建完毕 .局部变量 路径, 文本型 软件.禁止重复运行 () DNF窗口句柄 = 取句柄2 (“DNF.exe”, , “地下城与勇士”) .如果真 (DNF窗口句柄 = -1) 信息...

求高手解答易语言输入法注入自己要有超级模块才可以--------------------代码-----------------.版本 2.程序集 窗口程序集1.子程序 _按钮1_被单击输入法注入.激活 (取句柄2 (“DNF.exe”))输入法注入.安...

c语言文件输入输出嘿嘿,这东西还靠我啊o(∩_∩)o... #include<stdio.h> int main() { FILE *fp; char ch; fp = fopen("NewFile.txt","w"); do { ch = getchar(); fputc(ch,fp); }while(ch != '$');...

c语言数据文件输入输出你试试这个 #include <iostream> #include <fstream> #include <iomanip> #include <string> using namespace std; int main() { ofstream out("有地效起飞重量计算.txt", “w...

C语言的文件输入输出操作1.那个字符数组不是存储你的输入内容的,那个是相应的文件名及其符号链接(简单的或说是其路径)。但这个字符串的长度为10,此例应用为file1.c。2.实际运行中,你会先输入file1.c,然后...

C语言中的文件输入输出怎么用#include<stdio.h> int main(int argc,char** argv) { //读入 FILE *fp; int a;//这个用来保存要读入的数字 if((fp=fopen("a.in","rt"))==NULL) { printf("Cannot open file!"); r...

如何用C语言输出文件1、C语言标准库提供了一系列文件操作函数。文件操作函数一般以f+单词的形式来命名(f是file的简写),其声明位于stdio.h头文件当中。例如:fopen、fclose函数用于文件打开与关闭;fsc...

C语言输入输出文件数据新建文本文档,输入46 88,保存,文件名(包括后缀名)改为prob.in,保存在和你的源文件同目录。 .c或.cpp内输入 #include <stdio.h> int main() { int a, b; FILE *fp = fopen("prob.in...