Parse Error At End Of Input?!?!?!?!?!

This is a discussion on Parse Error At End Of Input?!?!?!?!?! within the C++ Programming forums, part of the General Programming Boards category; What does that mean!!! I have saerch hign and low all throughout my code and found nuthing. I just cannot ...

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    208

    Angry Parse Error At End Of Input?!?!?!?!?!

    What does that mean!!! I have saerch hign and low all throughout my code and found nuthing. I just cannot figure out why this is happening to me. Here is my code. Oh and it would be nice to also explain exactly what a parse error at end of input is because on other message boards people just give your awnsers and don't really help you to know why it is happening so u can fix it yourself next time.

    Code:
    #include <iostream.h>
    #include <stdlib.h>
    char word[502]; 
    int decimal[502];
    void binary();
    int main()
    {   char word[502]; 
        int decimal[502]; 
         cout<<"\nPlease Input Some Text\n";
         cin>>word;
         cout<<"\nThis Is Your Text In ASCII Decimals\n";
        for(int a=0;a<502;a++) 
        {decimal[a]=int(word[a]);
          cout<<decimal[a];}
          cout<<"This Is Your Text In Binary Numbers";
          binary();
           
    
    
          cout<<"\n\n Thats About It\n\n";
          system("PAUSE");
          return 0;
    }
    
    void binary()
    {     char letter;
          int len, ascii, binary[8], total;
       
          len = strlen(word);  /* get the number of characters in entry. */
       /* this loop is executed for each letter in the string. */
       for(int i = 0; i<len; i++)
       {
          total = 0;
          letter = word[i]; /* store the first letter */
          ascii = letter;    /* put that letter into an int, so we can 
                                see its ASCII number */ 
          while(ascii>0) /* This while loop converts the ASCII # into binary,
                            stores it backwards into the binary array. */
          {
             /* To get the binary code one must take the decimal number in
                question, take it and divide it by two repeatedly, save
                the remainder (which will become the binary number), save
                the whole number, divide by two, and repeat the whole
                process until 0 is reached.  This if-else statement serves
                this functionality, by getting the remainder of the ascii
                code, storing it in the array and then dividing the int
                ascii by two */
             if((ascii%2)==0)
             {
                binary[total] = 0;
                ascii = ascii/2;
                total++; /* increasing by one each time will yeild the
                            number of numbers in the array. */
             }
             else
             {
                binary[total] = 1;
                ascii = ascii/2;
                total++;
             }
          }
          total--; /* due to data type factors, the program will actually
                      add a 0 at the end of the array that is not supposed
                      to be there, decrementing total will solve this
                      problem, as that 0 will not be displayed. */
          /* this while loop displays the binary code for that letter. */
          while(total>=0)
          {
             cout<<binary[total];
             total--;
          }}
    by the way I am using dev-c++ version ummm 4. sumthing?

  2. #2
    Registered User
    Join Date
    May 2002
    Posts
    317
    This is what I noticed right off:
    Code:
    char word[502]; 
    int decimal[502];
    void binary();
    int main()
    {   char word[502]; 
        int decimal[502];
    You have redifined your variabled in main. This has the effect of masking your global variables so when you input to word you are inputting into the local definitions. Try removing the second def's.

  3. #3
    Registered User
    Join Date
    May 2002
    Posts
    208

    thanx but........

    I did that and by the way thanx for that because knowing that may save e a lot of problems in the future. I still got that same error though?
    Jeff Paddon
    Undergraduate Research Assistant
    Physics Department
    St. Francis Xavier University

  4. #4
    Registered User
    Join Date
    May 2002
    Posts
    317
    Try adding one more } (end bracket) at the end of your binary function. You had left one out, I did that and the prog compiled and ran fine.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 04:25 PM
  2. Interpreter.c
    By moussa in forum C Programming
    Replies: 4
    Last Post: 05-28-2008, 06:59 PM
  3. Errors
    By Rhidian in forum C Programming
    Replies: 10
    Last Post: 04-04-2005, 01:22 PM
  4. syntax error at end of input
    By cerin in forum C++ Programming
    Replies: 3
    Last Post: 03-06-2005, 01:06 AM
  5. Reading integers until end of input
    By nivo in forum C Programming
    Replies: 7
    Last Post: 10-20-2001, 05:18 PM

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