100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > c语言制作用户登录界面 【C语言开发】登陆界面

c语言制作用户登录界面 【C语言开发】登陆界面

时间:2024-05-28 23:52:15

相关推荐

c语言制作用户登录界面 【C语言开发】登陆界面

【C语言开发】登陆界面

发布时间:-10-11 11:43,

浏览次数:356

要求:

1.显示系统时间

2.绘制系统图案

3.输入用户名和密码,并保存到data.txt文件中

//define.h #ifndef _DELINE_H #define _DELINE_H #include #include

#include #include //显示系统时间 void showtime();

//绘制心形 void paintheart(); //输入用户名 int scanfuser(); //输入密码 int scanfpassword();

#endif //showtime.cpp #include "define.h" void showtime() { time_t timep; char

s[30]; time(&timep); strcpy(s,ctime(&timep)); printf("%s", s); }

//paintheart.cpp #include "define.h" void paintheart() { //心形函数 for (float y =

1.5f; y > -1.5f; y -= 0.1f) { for (float x = -1.5f; x < 1.5f; x += 0.05f) {

float a = x * x + y * y - 1; putchar(a * a * a - x * x * y * y * y <= 0.0f ?

'*' : ' '); } putchar('\n'); } } //scanfuser.cpp #include "define.h" int

scanfuser() { //定义用户名数组 char user[100]; //打印文字 printf("用户名:");

//输入用户名并保存到user数组中 scanf("%s",user); //printf("%s",user);

//将用户名信息保存在data.txt文件中 FILE *fpWrite=fopen("data.txt","a+"); //成功创建文件时

if(fpWrite) { //不为空时逐个字符保存 for(int i=0;user[i]!='\0';i++) {

fprintf(fpWrite,"%c",user[i]); } //关闭文件 fclose(fpWrite); //释放指针 fpWrite=NULL; }

return 0; } //scanfpassword.cpp #include "define.h" int scanfpassword() {

//声明密码数组 char password[100]; //打印文字 printf("密码:"); //输入密码并保存到数组中

scanf("%s",password); //printf("%s",password); //将用户名信息保存在data.txt文件中 FILE

*fpWrite=fopen("data.txt","a+"); //成功创建文件时 if(fpWrite) { //不为空时逐个字符保存 for(int

i=0;password[i]!='\0';i++) { fprintf(fpWrite,"%c",password[i]); } //关闭文件

fclose(fpWrite); //释放指针 fpWrite=NULL; } return 0; } //main.cpp #include

"define.h" int main() { //更改标题 system("title 登录界面"); //设置屏幕为白底红字 system("color

f4"); //设置窗口大小为80×40 system("mode con cols=80 lines=40"); //显示系统时间 showtime();

//绘制心形图案 paintheart(); //换行居中 printf("\n "); //输入用户名 scanfuser(); //换行居中

printf("\n "); //输入密码 scanfpassword(); return 0; }

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。