Thread: can't run this library systrm... help!

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    5

    can't run this library systrm... help!

    error found:
    "syntax error at end input"

    Code:
    #include<stdio.h>
    #include <conio.h>
    #include <string.h>
    
    main()
    {
    char choice;
    clrscr();
    cls();
    
    beg:
    printf("\n\n LIBRARY MANAGEMENT");
    printf("\n\n 1.MEMBER AREA");
    printf("\n\n 2.BOOK AREA");
    printf("\n\n 3.EXIT");
    printf("\n\n ENTER CHOICE: ");
    choice=getche();
    clrscr();
    switch(choice)
    {
    case '1':goto main1;
    case '2':goto main2;
    case '3':
    printf("\n THANK YOU");
    printf("\n press any key to exit");
    getch();
    default:
    goto beg;
    }
    
    main1:
    {
    FILE *fp,*ft,*fq;
    char another,choice;
    
    struct emp
    {
    char name[60];
    int age;
    int id;
    char address[100];
    };
    
    
    char empname[40];
    long int recize;
    int a;
    
    struct emp e;
    fp=fopen("EMP.DOC","rb+");
    if(fp==NULL)
    {
    fp=fopen("EMP.DOC","wb+");
    if(fp==NULL)
    {
    puts("\n Cannot open the file");
    }
    }
    
    recize=sizeof(e);
    while(1)
    {
    cls();
    printf("MEMBER AREA");
    gotorc(2,10);
    printf("1. ADD MEMBER");
    gotorc(3,10);
    printf("2. LIST MEMBERS");
    gotorc(4,10);
    printf("3. MODIFY MEMBER");
    gotorc(4,10);
    printf("4. DELETE MEMBER");
    gotorc(5,10);
    printf("5. EXIT");
    gotorc(7,10);
    printf(" ENTER YOUR CHOICE: ");
    fflush(stdin);
    choice=getche();
    switch(choice)
    {
    case '1':
    fseek(fp,0,SEEK_END);
    another='Y';
    while(another=='Y'|| another=='y')
    {
    //fq=fopen("MEMBERINFO.TXT","a+");
    printf("\n");
    printf(" Name: ");
    gets(e.name);
    //fputs(e.name,fq);
    printf("\n Age: ");
    scanf("%d",&e.age);
    //fprintf(e.age,fq);
    printf("\n I.D: ");
    scanf("%d",&e.id);
    //fprintf(e.id,fq);
    printf("\n Address: ");
    gets(e.address);
    //fputs(e.address,fq);
    printf("");
    scanf("%d",&a);
    fwrite(&e,recize,1,fp);
    //fclose(fq);
    printf("\n ADD ANOTHER MEMBER: ");
    fflush(stdin);
    another=getche();
    }
    break;
    
    case '2':
    rewind(fp);
    while(fread(&e,recize,1,fp)==1)
    {
    printf("\n %s %d",e.name,e.id);
    puts(e.name);
    printf("\t\b,");
    printf("%d",e.age);
    printf("\t\b,");
    printf("%d",e.id);
    printf("\t\b,");
    puts(e.address);
    }
    break;
    another='Y';
    while(another=='Y'|| another=='y')
    {
    printf("\n Enter name of the member to modify");
    gets(empname);
    rewind(fp);
    while(fread(&e,recize,1,fp)==1)
    {
    if(strcmp(e.name,empname)==0)
    {
    //fq=fopen("MEMBERMOD.TXT","a+");
    printf("\n Enter new name: ");
    gets(e.name);
    //fputs(empname,fq);
    //fputs("---modified as--- ",fq);
    //fputs(e.name,fq);
    printf("\n Enter new age: ");
    scanf("%d",&e.age);
    printf("\n Enter new ID: ");
    scanf("%d",&e.id);
    printf("\n Enter new address: ");
    gets(e.address);
    printf("");
    scanf("%d",&a);
    goto dot;
    }
    }
    }
    
    dot:
    {
    printf("\n\n Modify another record: ");
    fflush(stdin);
    another=getche();
    }
    
    break;
    
    case '3':
    another='y';
    while(another=='y'|| another=='Y')
    {
    printf("\n Enter member name to delete: ");
    gets(empname);
    ft=fopen("TEMP.DOC","wb");
    rewind(fp);
    while(fread(&e,recize,1,fp)==1)
    {
    if(strcmp(e.name,empname)!=0)
    fwrite(&e,recize,1,ft);
    }
    fclose(fp);
    fclose(ft);
    remove("EMP.DOC");
    rename("TEMP.DOC","EMP.DOC");
    printf("Member deleted");
    }
    fp=fopen("EMP.DOC","rb+");
    printf("\n Delete another member: ");
    fflush(stdin);
    another=getche();
    break;
    
    case '4':
    fclose(fp);
    goto beg;
    break;
    }
    
    
    main2:
    {
    FILE *fp,*ft,fe;
    char another,choice;
    
    struct emp1
    {
    char name[40];
    char category[40];
    char author[40];
    int id;
    int rid;
    char language[100];
    };
    
    struct emp1 e1;
    char empname[40];
    long int recize;
    int a,q,w;
    
    fp=fopen("EMP1.DOC","rb+");
    if(fp==NULL)
    {
    fp=fopen("EMP1.DOC","wb+");
    if(fp==NULL)
    {
    puts("\n Cannot open the file");
    }
    }
    recize=sizeof(e1);
    while(1)
    {
    cls1();
    printf("BOOK AREA");
    gotorc1(2,10);
    printf("1. ADD BOOK");
    gotorc1(3,10);
    printf("2. LIST BOOKS");
    gotorc1(4,10);
    printf("3. MODIFY BOOK INFO");
    gotorc1(4,10);
    printf("4. ISSUE BOOK");
    gotorc1(5,10);
    printf("5. EXIT");
    gotorc1(7,10);
    printf(" ENTER YOUR CHOICE: ");
    fflush(stdin);
    choice=getche();
    switch(choice)
    {
    case '1':
    fseek(fp,0,SEEK_END);
    another='Y';
    while(another=='Y'|| another=='y')
    {
    //fe=fopen("BOOKINFO.TXT","a+");
    printf("\n");
    printf(" Book name: ");
    gets(e1.name);
    //fputs(e1.name,fe);
    printf("\n Book i.d: ");
    scanf("%d",&e1.id);
    //fputs(e1.id,fe);
    printf("\n Authors name: ");
    gets(e1.author);
    //fputs(e1.author,fe);
    printf("");
    scanf("%d",&q);
    //printf("\n Rack i.d: ");
    //scanf("%d",&q);
    //scanf("%d",e1.rid);
    //scanf("%d",&q);
    printf("\n Book Category: ");
    gets(e1.category);
    //fputs(e1.category,fe);
    printf("");
    scanf("%d",&w);
    printf("\n Book Language: ");
    gets(e1.language);
    //fputs(e1.language,fe);
    scanf("%d",&q);
    fwrite(&e1,recize,1,fp);
    //fclose(fe);
    printf("\n ADD ANOTHER BOOK: ");
    fflush(stdin);
    another=getche();
    }
    break;
    
    case '2':
    rewind(fp);
    while(fread(&e,recize,1,fp)==1)
    printf("\n %s %d",e.name,e.id);
    puts(e.name);
    printf("\t\b,");
    printf("%d",e.age);
    printf("\t\b,");
    printf("%d",e.id);
    printf("\t\b,");
    puts(e.address);
    break;
    
    case '3':
    another='Y';
    while(another=='Y'|| another=='y')
    {
    printf("\n Enter name of the book to modify:");
    gets(empname);
    rewind(fp);
    while(fread(&e1,recize,1,fp)==1)
    {
    if(strcmp(e1.name,empname)==0)
    {
    //fe=fopen("BOOKMOD.TXT","a+");
    printf("\n Enter new book name: ");
    gets(e1.name);
    //fputs(empname,fe);
    //fputs("---modified as---",fe);
    //fputs(e1.name,fe);
    printf("\n Enter new rack id: ");
    scanf("%d",&e1.id);
    /*printf("\n Enter new ID: ");
    scanf("%d",e.id);
    printf("\n Enter new address: ");
    gets(e.address);
    printf("");
    scanf("%d",a);*/
    }
    }
    printf("\n\n Modify another record: ");
    fflush(stdin);
    //fclose(fe);
    another=getche();
    }
    break;
    
    case '4':
    another='y';
    while(another=='y'|| another=='Y')
    {
    printf("\n Enter book name to ISSUE: ");
    gets(empname);
    ft=fopen("TEMP1.DOC","wb");
    rewind(fp);
    while(fread(&e1,recize,1,fp)==1)
    {
    if(strcmp(e1.name,empname)!=0)
    fwrite(&e1,recize,1,ft);
    }
    fclose(fp);
    fclose(ft);
    remove("EMP1.DOC");
    rename("TEMP1.DOC","EMP1.DOC");
    fp=fopen("EMP1.DOC","rb+");
    printf("\n ISSUE another book: ");
    fflush(stdin);
    another=getche();
    }
    break;
    
    case '5':
    {
    fclose(fp);
    goto beg;
    }
    break;
    
    }
    getch();
    }

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    As though anyone is going to read that. Code tags +1, no indentation -5.

    Anyway, "syntax error at end of input" means "hey you need more close braces".

  3. #3
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by tabstop View Post
    Anyway, "syntax error at end of input" means "hey you need more close braces".
    See, why indent when you can IMAGINE the indentation in your head simply by counting curly braces!
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by brewbuck View Post
    See, why indent when you can IMAGINE the indentation in your head simply by counting curly braces!
    Haha. I typed "usually means" in my head but my fingers weren't paying attention. I did not, in fact, actually count the curly braces in the code. (I thought about using Ctrl-F to do so for approximately 0.35 seconds, but didn't.)

  5. #5
    Registered User
    Join Date
    Sep 2009
    Posts
    5
    i count on it... ill try again...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dev C++: can't run code
    By blurrymadness in forum C++ Programming
    Replies: 0
    Last Post: 08-07-2009, 07:33 PM
  2. Buidl Library with ./configure script
    By Jardon in forum C Programming
    Replies: 6
    Last Post: 07-24-2009, 09:36 AM
  3. triggering another program to run using serial port
    By infineonintern in forum C++ Programming
    Replies: 3
    Last Post: 07-22-2009, 05:16 AM
  4. static data structure in a library
    By melight in forum C Programming
    Replies: 6
    Last Post: 01-10-2009, 11:12 AM
  5. Visual C++ 2005 Express: Run Time Library
    By Rune Hunter in forum C++ Programming
    Replies: 4
    Last Post: 11-13-2005, 06:47 PM