Declaration Syntax error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mandogon
    New Member
    • Apr 2006
    • 31

    Declaration Syntax error

    Hello peoples
    i am having trouble compiling this program getting a the error is "Declaratio n Syntax error" using borland c++ bulider v.6 if any one can help thanks

    Code:
    void __fastcall TFrame2::FrameClick(TObject *Sender)
    {
     int main()
    {                                    //it is showing the error right here
    
            ifstream myfile("c:\fileopen.txt");
            if(myfile.is_open())
            {
                    while(!myfile.eof())
                    {
                            getline(myfile, line);
                            cout<<line<<endl;
                    }
                    myfile.close();
            }
            else cout<<"Unable to open file"<<endl;
    
    }
             return 0;
    }
    Last edited by Banfa; Sep 22 '06, 02:56 AM. Reason: Added [code] ... [/code] tags
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    You appear to be trying to declare main inside

    void __fastcall TFrame2::FrameC lick(TObject *Sender)

    this is wrong your structure should be

    Code:
    void __fastcall TFrame2::FrameClick(TObject *Sender)
    {
    // Function code
    }
    
    int main(int argc, char **argp)
    {
    // Function code
    }

    Comment

    • moh3n
      New Member
      • Dec 2007
      • 1

      #3
      Hey Mandogon did you get it? I mean did you solve your problem?
      I have also the same problem with a little difference.
      I have set all of my functioons right but I have still the same error.
      this is the programm.

      #include<stdio. h>
      #include<conio. h>
      #include<iostre am.h>
      int iszoj(long int a)
      {
      if (a%2!=0)
      return (0);
      return (1);
      }
      int isaval(long int b)
      {

      for(int i=2;i<b/2+1;i++){
      for(int j=2;j<i;j++)
      if(b%j==0)
      return (0);
      return (1);
      }
      void main()
      { //I have the error here.
      int a,b,second;
      clrscr();
      cin>>a>>b;
      for(int i=a;i<=b;i++)
      if (iszoj(i))
      for(int j=1;j<I/2+1;j++)
      if(isaval(j))
      {
      second =i-j;
      if(isaval(secon d))
      cout<<j<<"+"<<s econd<<"="<<i;
      }
      getch();
      }
      Last edited by moh3n; Dec 17 '07, 06:26 PM. Reason: Compliting...

      Comment

      • manjuks
        New Member
        • Dec 2007
        • 72

        #4
        closing brace of for loop in isaval(long int b) is missing. check it carefully.

        Comment

        Working...