503 c syntax error at end of input please help ..i cant spot any error out there ..

This is a discussion on 503 c syntax error at end of input please help ..i cant spot any error out there .. within the C Programming forums, part of the General Programming Boards category; Code: //Assignment sem2#include<stdio.h> #include<string.h> #include<stdlib.h> #define CLASS_SIZE 7 void GPA_BillProcessingSystem(); void Student_Records_Maintenance(); void Add(); void Modify(); void Delete(); void Process_Examination_Report(); ...

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    4

    503 c syntax error at end of input please help ..i cant spot any error out there ..

    Code:
    //Assignment sem2#include<stdio.h>
    #include<string.h>
    #include<stdlib.h>
    
    
    #define CLASS_SIZE  7
    
    
    void GPA_BillProcessingSystem();
    void Student_Records_Maintenance();
    void Add();
    void Modify();
    void Delete();
    void Process_Examination_Report();
    void Generate_Bill();
    
    
    
    
    typedef struct{
        char StudentId[30];
        char Name[30];
        char Gender;
        char Programme[5];
        int Year;
        int Sem;
        double Fees;
    }StudentData;
    StudentData data[CLASS_SIZE];
    
    
    FILE *StudentRecord;
    char conf, a1;
    char ID[30];
    int choice;
    int i=0, count=0, a=0;
    char NEWid[30];
        char NEWname[30];
        char NEWgender;
        char NEWprogram[5];
        int NEWyear;
        int NEWsem;
        double NEWfees;
    
    
    
    
    ///////MAIN
    int main()
    { 
        do{
        system("cls");
        
        printf(" ______    ______     ____  \n" 
            "   |         |      |   |    | \n"
            "   |     ___ |______|   |____| \n"
            "   |______|  |          |    | \n\n"
    
    
            "\t\t GPA and Bill Processing System \n"
            "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
            "\t[1] Student Records Maintenance\n"
            "\t[2] Process Examination Report\n"
            "\t[3] Generate Bill\n"
            "\t[4] Exit\n\n"
            "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
    
    
        printf("CHOOESE Your Choice :) ");
        scanf(" %d", &choice);
        
        switch(choice)
        {
        case 1:
            Student_Records_Maintenance();
            break;
        case 2:
            Process_Examination_Report();
            break;
        case 3:
            Generate_Bill();
            break;
        case 4:
            system("exit");
        default:
            printf("INVALID =) !\n");
        }
        }while(choice!=4);
    
    
        return 0;
    }
    
    
    //////////STUDENT RECORDS MAINTENANCE
    void Student_Records_Maintenance()
    {
        do{
        system("cls");
        
        printf(" ______    ______     __     __  \n"
            "   |         |      |   |  \\  /  | \n"
            "   |______   |______|   |   \\/   | \n"
            "    ______|  |    \\    |         | \n\n"
    
    
            "\t\t Student Records Maintenance\n"
            "=================================\n"
            "[1] ADD Student Record\n"
            "[2] MODIFY Student Record\n"
            "[3] DELETE Student Record\n"
            "[4] Main Menu\n\n");
    
    
        printf("CHOOSE Your Choice :) ");
        scanf("%d", &choice);
        
        switch(choice)
        {
        case 1:
            Add();
            break;
        case 2:
            Modify();
            break;
        case 3:
            Delete();
            break;
        case 4:
            main();
            break;
        default:
            printf("INVALID =) !\n");
        }
        }while(choice!=4);
        
    ///////ADD STUDENT
    void Add()
    {
        StudentRecord = fopen("StudentRecord.txt","a+");
    
    
        if((StudentRecord = fopen("StudentRecord.txt","a+"))==NULL)
        {
            prinft("Cannot Open StudentRecord.txt file!\n");
            exit(-1);
        }
        
        for(i=0 ; i<CLASS_SIZE ; i++)
        do
        {
            system("cls");
            printf(" ____    _____    _____  \n"
                "   |    |  |     )  |     ) \n"
                "   |____|  |     )  |     ) \n"
                "   |    |  |_____)  |_____) \n\n" 
                
                "\t\t ADD Student Records\n"
                "###########################\n\n");
                
        printf("Student ID : ");
        scanf(" %s", data[i].StudentId);
        fflush(stdin);
    
    
        printf("Name : ");
        scanf(" %[^\n]", data[i].Name);
        fflush(stdin);
    
    
        printf("Gender : ");
        scanf(" %c", &data[i].Gender);
        fflush(stdin);
    
    
        printf("Programme : ");
        scanf(" %s", data[i].Programme);
        fflush(stdin);
    
    
        printf("Year of Study : ");
        scanf(" %d", &data[i].Year);
        fflush(stdin);
    
    
        printf("Semester : ");
        scanf(" %d", &data[i].Sem);
        fflush(stdin);
    
    
        printf("Fees : ");
        scanf(" %lf", &data[i].Fees);
        fflush(stdin);
    
    
    
    
        fprintf(StudentRecord, " %s | %[^\n] | %c | %s | %d | %d | %.2f \n", data[i].StudentId, data[i].Name, data[i].Gender, data[i].Programme, data[i].Year, data[i].Sem, data[i].Fees);
        
        system("cls");
        printf("More Record [Y/N] :? " );
        scanf(" %c", &conf);
        fflush(stdin);
        
        count++;
        }while(conf=='Y' || conf=='y');
        fclose(StudentRecord);
    
    
    
    
        for(a=0; a<30; a++)
        {
            _sleep(30);
            printf("*");
        }
        printf("ADDED Student Record ^-^ !\n");
        system("cls");
        main();
    }
    
    
    ///////MODIFY STUDENT
    void Modify()
    {
        
    
    
        StudentRecord = fopen("StudentRecord.txt","r");
    
    
        if(StudentRecord==NULL)
        {
            printf("NOT FOUND!!\n");
        }
    
    
        while(fscanf(StudentRecord, " %s", data[i].StudentId)!=EOF)
        {
            fscanf(StudentRecord, " %[^\n] | %c | %[^\n] | %d | %d | %.2f", data[i].Name, &data[i].Gender, data[i].Programme, &data[i].Year, &data[i].Sem, &data[i].Fees);
            i++;
            fflush(stdin);
        }
        fclose(StudentRecord);
    
    
    
    
        system("cls");
        printf("Enter Student's ID to search :) ");
        scanf(" %s", ID);
    
    
        for(i=0;i<CLASS_SIZE+count;i++)
        {
            if(strcmp(data[i].StudentId, ID)==0)
            {
                system("cls");
                
                printf(" __    __    _____    _____ \n"
                    "   | \\  /  |  (     )  |     )\n"
                    "   |  \\/   |  (     )  |     )\n"
                    "   |        |  (_____)  |_____)\n\n"
    
    
                    "\t\t MODIFY Student Records\n"
                    "##############################\n\n");
                printf("Student ID : ");
                scanf(" %s", NEWid); 
                strcpy(data[i].StudentId, NEWid);
                fflush(stdin);
    
    
                printf("Student Name : ");
                scanf(" %[^\n]", NEWname);
                strcpy(data[i].Name, NEWname);
                fflush(stdin);
    
    
                printf("Gender : ");
                scanf(" %c", &NEWgender);
                   data[i].Gender = NEWgender;
                fflush(stdin);
    
    
                printf("Programme : ");
                scanf(" %s", NEWprogram);
                strcpy(data[i].Programme, NEWprogram); 
                fflush(stdin);
    
    
                printf("Year of Study : ");
                scanf(" %d", &NEWyear);
                data[i].Year = NEWyear;
                fflush(stdin);
                
                printf("Semester : ");
                scanf(" %d", &NEWsem);
                data[i].Sem = NEWsem;
                fflush(stdin);
    
    
                printf("Fees : ");
                scanf(" %lf", &NEWfees);
                data[i].Fees = NEWfees;
                fflush(stdin);
    
    
                system("cls");
                for(a=0; a<30; a++)
                {
                    _sleep(30);
                    printf(".");
                }
                printf("MODIFIED Student Record ^-^ !\n"
                    "==================================\n");
                printf("Student ID    :) %s     \n", data[i].StudentId);
                printf("Name          :) %[^\n] \n", data[i].Name);
                printf("Gender        :) %c     \n", data[i].Gender);
                printf("Programme     :) %s     \n", data[i].Programme);
                printf("Year of Study :) %d     \n", data[i].Year);
                printf("Semester      :) %d     \n", data[i].Sem);
                printf("Fees          :) %.2f   \n", data[i].Fees);
                fprintf(StudentRecord, " %s | %[^\n] | %c | %s | %d | %d | %.2f \n", data[i].StudentId, data[i].Name, data[i].Gender, data[i].Programme, data[i].Year, data[i].Sem, data[i].Fees);
            }
    
    
            else
            {
                for(a=0; a<30; a++);
                {
                    _sleep(30);
                    printf(".");
                }
                printf("Data NOT Found!!");
                system("cls");
                main();
            }
            fclose(StudentRecord);
            
            system("cls");
            main();
    
    
    }
    
    
    /////// DELETE STUDENT
    void Delete()
    {
        system("cls");
    
    
        StudentRecord = fopen("StudentRecord.txt","r");
    
    
        if(StudentRecord==NULL)
        {
            printf("NOT FOUND =) !\n");
        }
    
    
        while(fscanf(StudentRecord, "%s | %[^\n] | %c | %s | %d | %d | %lf", data[i].StudentId, data[i].Name, data[i].Gender, data[i].Programme, data[i].Year, data[i].Sem, data[i].Fees)!=EOF)
            {
                i++;
            }
    
    
            printf(" ______    ______            \n"
                "   |      )  |          |       \n"
                "   |      )  |______    |       \n"
                "   |______)  |______    |______ \n\n"
                
                 "\t\t DELETE Student Record\n"
                "#############################\n\n");
            printf("Enter Student's ID to Delete :) ");
            scanf(" %s", ID);
            fflush(stdin);
    
    
            
            if(strcmp(data[i].StudentId, ID)==0)
            {
              //data[i].StudentId = '\0';
            } 
            else
            {
                printf("INVALID =) !\n");
            }
        fclose(StudentRecord);
    }
    
    
    
    
    
    
    ///////PROCESS EXAMINATION REPORT
    void Process_Examination_Report()
    {
    
    
        char size[CLASS_SIZE][5]={0}, grade;
        double avgGPA=0, GPA=0, highGPA=0, lowGPA=0, total=0, num, sum=0;
        int index1=0, index=0, j=0;
    
    
        system("cls");
        printf(" ______    ______    ______    \n"      
            "   |      |  |         |      |   \n"
            "   |______|  |______   |______|   \n"
            "   |         |______   |    \\    \n\n"
            "\t\t Process Examination Report \n"
            "===================================\n\n");
        
        for(i=0; i<CLASS_SIZE + count; i++) //for row
        {
            printf("Enter the Grade for Student Number %d =)\n", i+1);
            for(j=0; j<CLASS_SIZE + count; j++) //for column
            {
                printf("Subject %d =) ", j+1);
                scanf(" %c", &size[i][5]);
            }
        }
        fflush(stdin);
    
    
        printf("  ______    ______    _______    _______    _______    _______ \n"
            "    |      |  |         |       |  (       )  |       |      |    \n"
            "    |______|  |______   |_______|  (       )  |_______|      |    \n"
            "    |    \\   |______   |          (_______)  |     \\       |    \n\n"
            "\t\t Examination Report \n"
            "===========================\n\n"
            "Student No. \t\t Subject  \n"
            "\t\t\t| S1  |  S2  |  S3  |  S4  |  S5  |  GPA  | \n"
            "\t\t\t|=====+======+======+======+======+=======| \n");
        for(i=0; i<CLASS_SIZE + count; i++)
        {
            //total
            printf("| %d |\n", i+1);
        
            for(j=0; j<5; j++)
            {
                //num
                printf("| %c |",size[i][5]);
    
    
                total+=num;
                num=(double)grade;
                if(total<lowGPA)
                {
                    lowGPA=total;
                    index=1;
                }
                if(total>highGPA)
                {
                    highGPA=total;
                    index1=1;
                }
                printf("| %.2f |", total/5);
                avgGPA = total/5;
    
    
        printf("\nAverage GPA = %.2f \n", avgGPA / (CLASS_SIZE + count));
        printf("Highest GPA = %.2f obtained by Student No %d \n", highGPA, index1);
        printf("Lowest GPA = %.2f obtained by Student No %d \n", lowGPA, index);
    
    
         switch(grade)
        {
         case 'A': case 'a':
            printf("Grade Point = 4.0\n");
            break;
         case 'B': case 'b':
            printf("Grade Point = 3.0\n");
            break;
        case 'C': case 'c':
             printf("Grade Point = 2.0\n");
             break;
        case 'D': case'd':
             printf("Grade Point = 1.0\n");
             break;
        case 'F': case 'f':
             printf("Grade Point = 0.0\n");
             break;
        default:
             printf("Error!\n");
        }
    }
    
    
    ///////GENERATE BILL
    void Generate_Bill()
    
    
    
    
    
    
    {
        char programme[5];
        double GPA, Fees, Bill, Sum;
    
    
        FILE *BILL;
        BILL = fopen("Bill.txt","w");
    
    
    
    
        printf(" _______    _______                      \n"   
            "   |       |      |       |         |       \n"
            "   |_______|      |       |         |       \n"
            "   |_______|   ___|___    |_____    |_____  \n\n"
            "\t\t Generate Bill \n"
            "======================\n\n");
        printf("Enter Your Programme :) ");
        scanf(" %s", programme);
        fflush(stdin);
    
    
        printf("Enter Your Programme's Fees :) RM ");
        scanf(" %lf", &Fees);
        fflush(stdin);
    
    
        printf("Enter Your GPA :)  ");
        scanf(" %lf", &GPA);
        fflush(stdin);
    
    
        if(GPA>=3.85)
        {
            Bill = Fees * 1.00;
            Sum = Bill;
            printf("ScholarShip 100%% ! RM%.2f \n", Sum);
        }
        else if(GPA>=3.75)
        {
            Bill = Fees * 0.75;
            Sum = Bill;
            printf("ScholarShip 75%% ! RM%.2f \n", Sum);
        }
        else if(GPA>=3.65)
        {
            Bill = Fees * 0.50;
            Sum = Bill;
            printf("ScholarShip 50%% ! RM%.2f \n", Sum);
        }
        else
        {
            Bill = Fees;
            Sum = Bill;
            printf("ScholarShip NOT available..Thank You =) !\n");
        }
        
        fprintf(BILL, "|BBBBBB   IIIIII LLLLLL LLLLLLL|\n");
        fprintf(BILL, "|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|\n");
        fprintf(BILL, "|Programme      |    %s        |\n", programme);
        fprintf(BILL, "|Programme Fees | RM %.2f      |\n", Fees);
        fprintf(BILL, "|ScholarShip    |    %.2f      |\n", Bill);
        fprintf(BILL, "|Sum            | RM %.2f      |\n", Sum);
        fprintf(BILL, "|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|\n");
    
    
    
    
    
    
    }
    Keep showing syntax error at the end of input ...but i cant find any it ..

  2. #2
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,444
    Always start resolving errors from the beginning of the list, because the later ones may be a result of a previous error. C reads the file top-down. Also make sure you compile with your warnings turned all the way up. Here are the errors I get:
    Code:
    $ gcc -Wall -g -std=c99  report.c   -o report
    report.c:32: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
    report.c: In function ‘main’:
    report.c:54: warning: implicit declaration of function ‘printf’
    report.c:54: warning: incompatible implicit declaration of built-in function ‘printf’
    report.c:70: warning: implicit declaration of function ‘scanf’
    report.c:70: warning: incompatible implicit declaration of built-in function ‘scanf’
    report.c: In function ‘Student_Records_Maintenance’:
    report.c:101: warning: incompatible implicit declaration of built-in function ‘printf’
    report.c:116: warning: incompatible implicit declaration of built-in function ‘scanf’
    report.c: In function ‘Add’:
    report.c:140: error: ‘StudentRecord’ undeclared (first use in this function)
    report.c:140: error: (Each undeclared identifier is reported only once
    report.c:140: error: for each function it appears in.)
    report.c:140: warning: implicit declaration of function ‘fopen’
    report.c:145: warning: implicit declaration of function ‘prinft’
    report.c:153: warning: incompatible implicit declaration of built-in function ‘printf’
    report.c:162: warning: incompatible implicit declaration of built-in function ‘scanf’
    report.c:163: warning: implicit declaration of function ‘fflush’
    report.c:163: error: ‘stdin’ undeclared (first use in this function)
    report.c:198: warning: implicit declaration of function ‘fprintf’
    report.c:198: warning: incompatible implicit declaration of built-in function ‘fprintf’
    report.c:207: warning: implicit declaration of function ‘fclose’
    report.c:214: warning: implicit declaration of function ‘_sleep’
    report.c:215: warning: incompatible implicit declaration of built-in function ‘printf’
    report.c:217: warning: incompatible implicit declaration of built-in function ‘printf’
    report.c: In function ‘Modify’:
    report.c:229: error: ‘StudentRecord’ undeclared (first use in this function)
    report.c:234: warning: incompatible implicit declaration of built-in function ‘printf’
    report.c:238: warning: implicit declaration of function ‘fscanf’
    report.c:238: warning: incompatible implicit declaration of built-in function ‘fscanf’
    report.c:238: error: ‘EOF’ undeclared (first use in this function)
    report.c:242: error: ‘stdin’ undeclared (first use in this function)
    report.c:250: warning: incompatible implicit declaration of built-in function ‘printf’
    report.c:251: warning: incompatible implicit declaration of built-in function ‘scanf’
    report.c:318: warning: unknown conversion type character ‘[’ in format
    report.c:318: warning: too many arguments for format
    report.c:324: warning: incompatible implicit declaration of built-in function ‘fprintf’
    report.c: In function ‘Delete’:
    report.c:363: warning: incompatible implicit declaration of built-in function ‘fscanf’
    report.c: In function ‘Process_Examination_Report’:
    report.c:403: warning: missing braces around initializer
    report.c:403: warning: (near initialization for ‘size[0]’)
    report.c: In function ‘Generate_Bill’:
    report.c:505: error: ‘FILE’ undeclared (first use in this function)
    report.c:505: error: ‘BILL’ undeclared (first use in this function)
    report.c:557: warning: incompatible implicit declaration of built-in function ‘fprintf’
    report.c: In function ‘Process_Examination_Report’:
    report.c:570: error: expected declaration or statement at end of input
    report.c:570: error: expected declaration or statement at end of input
    report.c:404: warning: unused variable ‘sum’
    report.c:404: warning: unused variable ‘GPA’
    report.c: In function ‘Modify’:
    report.c:570: error: expected declaration or statement at end of input
    report.c: In function ‘Student_Records_Maintenance’:
    report.c:570: error: expected declaration or statement at end of input
    Many of those will go away simply by #including <stdio.h>. Then you need to read up on how to properly use printf/scanf and the format specifiers. Googling some tutorials would be a good idea. As for the error you mentioned at end of input, you seem to be missing a closing }. This would be much more apparent if you had and used an editor with an auto-indent feature.

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,451
    So when did you last compile it (or test it)?
    A development process

    Or have you just bashed in 500 lines of code and now you're stuck.

    line 136 seems promising.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,444
    Follow up: It would greatly benefit you to first get a clear understanding of the problem and requirement. Then, plan your solution thoroughly on paper, and run through some test examples on paper, at a higher level. Then, begin coding in small increments. Compile and test after every 10-20 lines or so, and make sure you resolve all errors and warnings before proceeding. This will make it much easier to find and fix errors.

  5. #5
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Line 1 ... you have a #include hidden behind a comment ... check that it's not a copy paste error.
    Check that all your quotes, braces and brackets are correctly matched.
    Also make sure there is at least one blank like at the end of your file.

    Now a few tips...

    Concentrate on substance, not form. All those fancy looking ascii text menus do little more than use up screen geography and contribute absolutely nothing to the function of your program. Fancy ain't what you're after in a console program.

    Lose all the system("cls") calls... Operators rapidly become very annoyed with screens that keep going blank on them.

    Lose all the calls to main() ... You must never call main() from inside another function, it will eventually crash the program. Allow the function to return to main() on it's own, and rearrange your main() function to accomodate it.

    Lose all calls to fflush(stdin)... this is non-standard behaviour that on many compilers is also undefined (i.e. not trustworthy)

    Check the FILE pointer after opening each file and abort the program it it doesn't open. Accessing an unopened file will cause an Access Violation and may require a system restart (depending on Windows version).

    You are using several global variables... you should move them into functions wherever possible.


    On the plus side I can see you've made some real effort here and your code layout is pretty good.

  6. #6
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,831
    - Missing closed brace on function Student_Records_Maintenance().
    - Misspelled printf near beginning of function Add()
    - Parameter type and format string mismatch in fprintf(StudentRecord, ... in function Add()
    - Microsoft compiler doesn't like _sleep(), suggests using sleep() (no underscore), but in your environment this might not be an issue.
    - Missing closed brace on function Modify()
    - Two missing closed braces on function Process_Examination_Report()

  7. #7
    Registered User
    Join Date
    Nov 2011
    Posts
    4
    ok i am done all the error and now pop out a new error which is C:\Users\CcL\Desktop\123.c||In function 'Add':|

    undefined reference to `prinft'|


    i cant find any word "prinft"out there ...

  8. #8
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,831
    Because it's a spelling mistake as I mentioned before.

  9. #9
    Registered User
    Join Date
    Nov 2011
    Posts
    4
    ok..thanks guys !! you all help alot !!!! thanks !

  10. #10
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,451
    Continued here -> Logical error. e
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Spot the syntax error
    By ender6456 in forum C Programming
    Replies: 2
    Last Post: 11-29-2011, 10:54 AM
  2. syntax error at end of input
    By tetartos in forum C Programming
    Replies: 4
    Last Post: 11-27-2011, 08:18 AM
  3. syntax error at end of input
    By djdato in forum C Programming
    Replies: 3
    Last Post: 05-22-2010, 10:10 AM
  4. syntax error at end of input
    By sauoon in forum C++ Programming
    Replies: 5
    Last Post: 12-14-2009, 02:48 AM
  5. syntax error at end of input
    By cerin in forum C++ Programming
    Replies: 3
    Last Post: 03-06-2005, 12:06 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21