What is the cause of declaration syntax error?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • akhilandrews
    New Member
    • Jan 2015
    • 8

    What is the cause of declaration syntax error?

    Code:
    #include<iostream.h>
    #include<stdio.h>
    #include<fstream.h>
    #include<conio.h>
    void main()
    {
         clrscr();
         char i;
         ofstream fout("C:\\TurboC4\\TC\\BIN\\Article.txt"ios::out)
         [B]if(!fout.fail())[/B] //error <<<<<<<<<<<<
         {
              cout<<"/nOpened successfully"
              cout<<"/nEnter character:";
              i=getchar();
              while(i!=$)
              {
                   fout.put(i);
                   i=getchar();
              }
         }
         else
         {
              cout<<"/nError in Opening";
         }
         fout.close();
         ifstream.fin("C:\\TurboC4\\TC\\BIN\\Article.txt"ios::in);
         i=fin.get();
         cout<<"\nCurrent Contents";
         while(!fin.eof())
         {
              cout<<i;
              i=fin.get()
         }
         fin.close();
         getch();
         return;
    }

    I'm getting a declaration syntax error at line 10, I'm not sure why please explain the cause of this error and the correction required, Thanks in advance!
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    It looks like line 9 does not end in a semi-colon.

    Comment

    Working...