资源简介

cpp格式 程序源代码 共424行 理解文件的概念 理解文件存储的特点

资源截图

代码片段和文件信息

/*****************文件管理系统*************************************/
#include
#include//不容易归类的标准函数库 
#include
#include
#include
#include//非标准文件输入输出操作的代码符号属性 
#include
#include

int init()//初始化操作界面函数 
{
    int i;
    printf(“**********************\n“);
    printf(“FILE MANAGE SYSTEM\n“);
    printf(“**********************\n“);
    printf(“NETWORK033 Cai Guiquan NO.1\n“);
    printf(“1-Creat     File\n“);
    printf(“2-Delete    File\n“);
    printf(“3-OPen      File\n“);
    printf(“4-Write     File\n“);
    printf(“5-Locate    File\n“);
    printf(“6-Modify    File\n“);
    printf(“7-Copy      File\n“);
    printf(“8-Move      File\n“);
    printf(“9-Cataloge  File\n“);
    printf(“10-Exit     File\n“);
    printf(“Pleade Choose:“);
    scanf(“%d“&i);
    return(i);//选择相应的序号,执行相应的操作 
}

main()
{
      int xijflag=1;    
      char name[5]name1[15]name2[40];
      char choicech;
      int handlestatus;//文件定义的指针和状态
      FILE *fp;
      while(flag)//初始化系统界面 
      { 
           i=init();
           getchar();
           switch(i){
                     case 1:label1://创建文本操作 
                     printf(“Creat     File\n“);
                     for(j=0;j<40;j++)
                     printf(“=“);
                     printf(“\n\nPlease input the creating file name:\n“);
                     scanf(“%s“name);
                     getchar();
                     fp=fopen(name“w+“);//按指定的文件方式创建文件
                     if(!fp)
                     {
                            printf(“\n creating fail“);
                            getchar();
                            printf(“\nInput again(Y or N)“);
                            scanf(“%c“&choice);
                            getchar();
                            if(choice==‘y‘ ||choice==‘Y‘)
                            goto label1;
                            } 
                     else{
                          printf(“\nThe file is created“);
                          printf(“Do you now input content of the file?(Y or N):“);
                          while(1)//输入创建文件的内容 
                          {
                            scanf(“%c“&choice);
                            if(choice==‘y‘ ||choice==‘Y‘ ||choice==‘n‘ ||choice==‘N‘)  
                            break;
                            else
                            printf(“\nError!Please input again!“);                           
                           } 
                          if(choice==‘y‘ ||choice==‘Y‘)
                          {
                               printf(“\nNow input content to the file(End with‘#‘):\n\n“);
                               fp=fopen(name“w+“);//把内容存放到fp指向的文件中去
                               ch=getchar();
                               while(ch!=‘#‘)
                               {
                                  fputc(chfp);
             

评论

共有 条评论