By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,722 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

Declaration Syntax error

P: 31
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
Share this Question
Share on Google+
3 Replies


Banfa
Expert Mod 5K+
P: 8,916
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

P: 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

P: 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.