468,497 Members | 1,875 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,497 developers. It's quick & easy.

Declaration Syntax error

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

Expand|Select|Wrap|Line Numbers
  1. void __fastcall TFrame2::FrameClick(TObject *Sender)
  2. {
  3.  int main()
  4. {                                    //it is showing the error right here
  5.  
  6.         ifstream myfile("c:\fileopen.txt");
  7.         if(myfile.is_open())
  8.         {
  9.                 while(!myfile.eof())
  10.                 {
  11.                         getline(myfile, line);
  12.                         cout<<line<<endl;
  13.                 }
  14.                 myfile.close();
  15.         }
  16.         else cout<<"Unable to open file"<<endl;
  17.  
  18. }
  19.          return 0;
  20. }
  21.  
Sep 21 '06 #1
3 16692
Banfa
9,055 Expert Mod 8TB
You appear to be trying to declare main inside

void __fastcall TFrame2::FrameClick(TObject *Sender)

this is wrong your structure should be

Expand|Select|Wrap|Line Numbers
  1. void __fastcall TFrame2::FrameClick(TObject *Sender)
  2. {
  3. // Function code
  4. }
  5.  
  6. int main(int argc, char **argp)
  7. {
  8. // Function code
  9. }
  10.  
Sep 22 '06 #2
moh3n
1
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<iostream.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(second))
cout<<j<<"+"<<second<<"="<<i;
}
getch();
}
Dec 17 '07 #3
manjuks
72
closing brace of for loop in isaval(long int b) is missing. check it carefully.
Dec 18 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

11 posts views Thread by Blondie1966 | last post: by
3 posts views Thread by dianaroslan | last post: by
reply views Thread by NPC403 | last post: by
3 posts views Thread by gieforce | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.