}
user_num++;
//fulfill the new user char name[10],psw[10]; User *check; char buffer[2];
fgets(buffer,2,stdin);
unr:printf(%used):\\n\
scanf(\
check=user_head; while(check!=add) {
if(strcmp(name,check->name)==0) {
printf(\goto unr; }
check=check->next; }
strcpy(add->name,name);
fgets(buffer,2,stdin); printf(\fgets(psw,10,stdin); strcpy(add->psw,psw);
add->conHead=NULL; add->c_num=0;
//success
printf(\
return; }
//step0 int login()
5
{
if(user_head==NULL) {
printf(\return 0; }
char buffer[2];
fgets(buffer,2,stdin);
char name[10],psw[10]; User *check;
printf(%unl:printf(\scanf(\
if(name[0]=='#') return 0;
check=user_head; while(check!=NULL) {
if(!strcmp(check->name,name)) break; else
check=check->next; }
if(check==NULL) {
printf(\goto unl; }
//match password
fgets(buffer,2,stdin); printf(\fgets(psw,11,stdin);
if(strcmp(psw,check->psw)!=0) {
printf(\goto unl; }
printf(\cur_user=check;
6
return 1; }
void main(int argc, char* argv[]) {
user_num=0; user_head=NULL; cur_user=NULL; int choice; for(;;) {
printf(\printf(\printf(\printf(\
printf(\printf(\%d user exist\\n\printf(\
scanf(\switch(choice) {
case 1: registe();continue; case 2:if(login()) MenuUser(); continue;
case 0:printf(\default:printf(\} } }
3.2 目录管理系统:
7
截图3-2
相关核心代码: //step0-1
void MenuUser() {
void FolderCreate(); void FolderDelete();
void FolderViewAllFiles(); void FolderIntoFolder();
void absolutePathFileController();
User *current;
Content *goThrough;
current=cur_user;
goThrough=current->conHead;
for(;;) {
printf(\printf(\printf(\printf(\printf(\
printf(\printf(\
printf(\printf(\view all your folders below: %d folders total\\n\if(current->conHead==NULL)
8
printf(\|\\n no folder.\\n\else {
goThrough=current->conHead; while(goThrough!=NULL) {
printf(\|\\n %s\\n\goThrough=goThrough->next; } }
printf(\printf(\int choice;
scanf(\switch(choice) {
case 1:FolderCreate();continue; case 2:FolderIntoFolder();continue; case 3:FolderDelete();continue;
case 4:FolderViewAllFiles();continue;
case 5:absolutePathFileController();continue; case 6:printf(\
case 0:printf(\default:printf(\} } }
//step1
void FolderCreate() {
User *user; user=cur_user;
//allocate new memory block for new folder Content *add,*last;
add=(Content *)malloc(sizeof(Content)); add->next=NULL;
if(user->conHead==NULL) user->conHead=add; else
9