900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > 【C语言开发】登陆界面

【C语言开发】登陆界面

时间:2022-11-13 02:35:16

相关推荐

【C语言开发】登陆界面

要求:

1.显示系统时间

2.绘制系统图案

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

//define.h#ifndef _DELINE_H#define _DELINE_H#include <stdio.h>#include <time.h>#include <string.h>#include <stdlib.h>//显示系统时间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×40system("mode con cols=80 lines=40");//显示系统时间showtime();//绘制心形图案paintheart();//换行居中printf("\n ");//输入用户名scanfuser();//换行居中printf("\n ");//输入密码scanfpassword();return 0;}

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