Hello World
来源:互联网 发布:百度云盘网络异常1 编辑:程序博客网 时间:2024/06/05 11:16
这是第一篇在CSDN上的日志,我不知道该写些什么。
跟QQ空间不一样,感觉不能灌水。
//头文件
#ifndef _KESHE_#define _KESHE_#endif#pragma once#define STU struct stu#define USER struct user
STU{ int num; char name[50]; char sex; int age; char place[50]; char department[50]; char majar[50]; char clas[50]; STU *next; STU *pre; };
USER{ char admin[100],root[100]; USER *next; };
#define login 'a'#define exit 'b'#define add 'a'#define change 'b' #define del 'c'#define find 'd'#define output 'e'#define read 'f'#define statistics 'g'#define display 'h'#define quit 'i'
void Add();void Change();void Del();void Find();void Output();void Read();void Maintenance();int list();void hidden();void Display();void Login();void show();void menu();
//源文件
#include<stdio.h>#include<windows.h>#include"keshe.h"#include<string.h >#include<stdlib.h>STU static *head=NULL;void Add(){STU *stu1=head,*stu2;char answer[100];if(head==NULL){printf(" Do you want to creat a new table?(Y|N)");scanf("%s",answer);if(!strcmp("Y",answer)){stu1=stu2=(STU *)malloc(sizeof(STU));head=stu1;stu1->pre=head;stu1->next=NULL;}else{printf(" Back to menu.");list();}}while(stu1->next!=NULL)stu1=stu1->next;while(1){stu2=(STU *)malloc(sizeof(STU));printf("Print the num:");scanf("%d",&stu2->num);printf("Print the name:");scanf("%s",stu2->name);printf("Print the sex(m or w):");scanf("%s",&stu2->sex);printf("Print the age:");scanf("%d",&stu2->age);printf("Print the place:");scanf("%s",stu2->place);printf("Print the department:");scanf("%s",stu2->department);printf("Print the majar:");scanf("%s",stu2->majar);printf("Print the clas:");scanf("%s",stu2->clas);stu1->next=stu2;stu2->pre=stu1;stu2->next=NULL;stu1=stu2;printf(" Do you want to add again?(Y|N)");scanf("%s",answer);if(!strcmp("Y",answer));elselist();}}void Change(){char answer[100],t=0;STU *stu1=head;printf("please scanf which num you want to change:");scanf("%d",&answer[0]);while(stu1->num!=answer[0]){if(stu1->next!=NULL)stu1=stu1->next;else{printf("your scanf is wrong");list();}}printf("num|name|sex|age|place|department|majar|clas\nwhat do you change?");scanf("%s",answer);if(!strcmp("num",answer)){while(stu1->num!=answer[0]){printf("please scanf the num after change:");scanf("%d",&answer[0]);if(stu1->next==NULL&&stu1->num!=answer[0]){stu1->num=answer[0];printf("success");list();}else{printf("the num has been had\n");system("pause");list();}}}else if(!strcmp("name",answer)){printf("please scanf the name after change:");scanf("%s",answer);strcpy(stu1->name,answer);printf("success");list();}else if(!strcmp("sex",answer)){printf("please scanf the sex after change:");scanf("%s",answer);stu1->num=answer[0];printf("success");list();}else if(!strcmp("age",answer)){printf("please scanf the age after change:");scanf("%d",&answer[0]);stu1->num=answer[0];printf("success");list();}else if(!strcmp("place",answer)){printf("please scanf the place after change:");scanf("%s",answer);strcpy(stu1->place,answer);printf("success");list();}else if(!strcmp("department",answer)){printf("please scanf the department after change:");scanf("%s",answer);strcpy(stu1->department,answer);printf("success");list();}else if(!strcmp("majar",answer)){printf("please scanf the majar after change:");scanf("%s",answer);strcpy(stu1->majar,answer);printf("success");list();}else if(!strcmp("clas",answer)){printf("please scanf the clas after change:");scanf("%s",answer);strcpy(stu1->clas,answer);printf("success");list();}else{printf("your scanf is wrong");list();}}void Del(){char answer[100];STU *stu1=head;printf("who do you del?please scanf name:");scanf("%s",answer);while(strcmp(stu1->name,answer))if(stu1->next!=NULL)stu1=stu1->next;else{printf("your scanf is wrong");list();}if(stu1->next!=NULL)stu1->pre->next=stu1->next;elsestu1->pre->next=NULL;free(stu1);printf("success");list();}void Find(){STU *stu1=head;char answer[100];printf("which num do you find?");scanf("%d",&answer[0]);while(stu1->num!=answer[0]){if(stu1->next!=NULL)stu1=stu1->next;else{printf("your scanf is wrong");list();}}printf("num|name|sex|age|place|department|majar|clas\n");printf("%d,%s,%c,%d,%s,%s,%s,%s\n",stu1->num,stu1->name,stu1->sex,stu1->age,stu1->place,stu1->department,stu1->majar,stu1->clas);system("pause");list();}void Output(){STU *stu1=head->next;FILE *fp;fp=fopen("date.dat","w");while(stu1!=NULL){fprintf(fp,"%d %s %c %d %s %s %s %s\n",stu1->num,stu1->name,stu1->sex,stu1->age,stu1->place,stu1->department,stu1->majar,stu1->clas);stu1=stu1->next;}fclose(fp);system("pause");list();}void Read(){STU *stu1,*stu2=head;FILE *fp;char t;fp=fopen("date.dat","r");stu2=(STU *)malloc(sizeof(STU));head=stu2;while(!feof(fp)){stu1=(STU *)malloc(sizeof(STU));fscanf(fp,"%d %s %c %d %s %s %s %s\n",&stu1->num,stu1->name,&stu1->sex,&stu1->age,stu1->place,stu1->department,stu1->majar,stu1->clas);stu2->next=stu1;stu1->pre=stu2;stu2=stu2->next;}stu2->next=NULL;fclose(fp);system("pause");list();}void Statistics(){STU *stu1=head;char answer[100];printf("");}void Display(){STU *stu1=head->next;printf("num|name|sex|age|place|department|majar|clas\n");while(stu1!=NULL){printf("%d,%s,%c,%d,%s,%s,%s,%s\n",stu1->num,stu1->name,stu1->sex,stu1->age,stu1->place,stu1->department,stu1->majar,stu1->clas);stu1=stu1->next;}system("pause");list();}int list(){char option=0;Sleep(1000);system("cls");if(head==NULL){printf("——————————————————————————————————————\n");printf(" a.add \n");printf(" f.read \n");printf(" i.quit \n");printf("——————————————————————————————————————\n");while(option=getch()){if(add==option){Add();}else if(read==option){Read();}else if(quit==option){menu();}else{printf(" Your scanf is wrong!");list();}}}else{printf("——————————————————————————————————————\n");printf(" a.add \n");printf(" b.change \n");printf(" c.del \n");printf(" d.find \n");if(head->next!=NULL)printf(" e.output \n");printf(" f.read \n");printf(" g.statistics \n");printf(" h.display \n");printf(" i.quit \n");printf("——————————————————————————————————————\n");while(option=getch()){if(add==option){Add();}else if(change==option)Change();else if(del==option){Del();}else if(find==option){Find();}else if(output==option){Output();}else if(read==option){Read();}else if(statistics==option){Statistics();}else if(quit==option){menu();}else if(display==option){Display();}else{printf(" Your scanf is wrong!");list();}}}}void show(){system("cls");printf("——————————————————————————————————————\n");printf(" a.login \n");printf(" b.exit \n");printf("——————————————————————————————————————\n");}void Login(){int n=0;char username[100],password[100];Sleep(1000);system("cls");show();printf(" username:");scanf("%s",&username); printf(" password:");for(;password[n]!='\n';n++){password[n]=getch();if(password[n]==13){password[n]='\0';printf("\n");break;}printf("*");}if(!strcmp("admin",username)&&!strcmp(password,"root")){printf(" Login successful!");Sleep(1000);system("cls");if(head==NULL)Add();elselist();}else{printf(" Username or Password is wrong!");Login();}}void menu(){char option=0;show();while(option=getch()){if(option==login){Login();}else{printf(" Your input is wrong");Sleep(1000);system("cls");menu();}}}void hidden()//隐藏光标{CONSOLE_CURSOR_INFO cci;GetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cci);cci.bVisible=0;//赋1为显示,赋0为隐藏SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cci);}void main(){hidden();while(1){menu();}}
/*
不好意思、。。。注释比较少,这是我现在的一个坏习惯。
这是我学C的第一个激动,我终于把C语言的文件那一部分给消化了。
另外,我想每一个学C的人都有疑问吧,因为我们学的时候,敲出来的是在cmd命令框下的console程序。
我当时就一直在想怎么编写出来图形界面的程序,在图书馆找了半天书,终于看到了graphics.H这个头文件。
我一激动,立马把代码敲在了VC++ 6.0 IDE窗口下,一按F5,我的那个伤啊,error:未发现graphics.H。
然后我就在想,是不是能去百度一个头文件放进去呢?
于是#include"graphics.h"
F5
error一排刷下来,当时脸都绿了,打开头文件一看,除了大量的宏定义跟函数声明,啥也没有。这件事也就告一段落。
现在我才明白:不止*.h在起作用。
*.lib跟动态链接库 *.dll文件也有很大的作用
提供头文件的商家怕头文件的内容暴露,做成了编译成*.dll动态链接库
最近在看《汇编语言(王爽著)》还有《windows程序设计》。
*/
- Hello World!【Hello World】
- Hello, world!
- Hello World!
- Hello world!
- Hello World!
- Hello World!
- hello world!
- Hello World !
- Hello,World!
- Hello World!
- Hello world!
- Hello World!
- Hello World
- Hello World
- Hello world
- Hello World!
- Hello world
- Hello World !
- Struts2的工作原理
- Objective-C中的Block
- 在无序序列中找出最长的连续序列 Longest Consecutive Sequence
- ClassNotFoundException, org.jboss.netty.channel.ChannelPipelineFactory 缺少jar包
- [LeetCode]Palindrome Number
- Hello World
- Java 多线程实现方法
- Leetcode: 4Sum
- windows安装scrapy
- Binary Tree Preorder Traversal
- 充分认识我们的免疫系统
- 是男人就下100层【第一层】——高仿微信界面(6)
- [转]《Python编程金典》读书笔记
- ubuntu Java环境配置