0

I'm facing titled problem in my assignment at line 60. Please anyone help me as quick as possible.

59 void storeFile();
60 {
61 cout<< "All the data members are stored in file." << endl;
62 
63 ofstream outFile;
64 const char *outputFileName = ("record.txt");
65 outFile.open(outputFileName, ios::out);
66 
67 if(!outFile)
68 {
69      cout<< "\nUnable to open the file." << outputFileName << endl;
70      }
71 
72      else
73          {
74              outFile VUID; endl;
75              outFile campusID; endl;
76              outFile studentName; endl;
77              outFile fatherName; endl;
78                  }
79 };

error: expected unqualified-id before '{' token c++ at line 60

Tiro Sagacious
  • 31
  • 1
  • 1
  • 2
  • 2
    remove the last semicolon on line 59 – bobah Jun 26 '13 at 07:42
  • 5
    This question appears to be off-topic because it is about typewriting. –  Jun 26 '13 at 07:44
  • I can't figure out how a quick Google search about that exact error didn't reply to your question... – Joum Jun 26 '13 at 07:52
  • And now I just looked to the right... -_-' I don't want to live in this planet anymore... – Joum Jun 26 '13 at 07:53
  • I removed ; from the line 59 but now facing error at line 74 column 13 [Error] expected ';' before 'VUID' – Tiro Sagacious Jun 26 '13 at 07:54
  • See http://stackoverflow.com/questions/6404547/c-programming-error-expected-unqualified-id-before-token for some good pointers, at least regarding your original issue, you can probably find more here on so... – Anders Jun 26 '13 at 07:56
  • ..btw - it appears you're taking the same class... ask your classmate instead.. http://stackoverflow.com/questions/17314497/cannot-write-the-data-in-the-file-no-error-in-the-program-c – Anders Jun 26 '13 at 08:01

3 Answers3

9

Remove the ; at the end of line 59.

By the way, as ChrisCM and U2CO3 have written, the ; at end of line 79 is not needed, even if that one does not generate a compilation error.

Didier Trosset
  • 36,376
  • 13
  • 83
  • 122
  • 1
    The one at line 79 is also unnecessary. – MobA11y Jun 26 '13 at 07:43
  • @H2CO3 ChrisCM's comment was about 10 seconds before yours :D – Philip Kendall Jun 26 '13 at 07:45
  • @PhilipKendall I was writing mine :D –  Jun 26 '13 at 07:45
  • 2
    All is fair in love and the grabbing of obvious stackoverflow answers. – MobA11y Jun 26 '13 at 07:46
  • 1
    @H2CO3 there's no shame in that... Don't hate the playa, hate the game... :D – Joum Jun 26 '13 at 07:51
  • I removed ; from the line 59 but now facing error at line 74 column 13 [Error] expected ';' before 'VUID' – Tiro Sagacious Jun 26 '13 at 07:53
  • 1
    @TiroSagacious You'll have to find some teaching resource about how to use C++ `ostream` objects. Try `outFile << VUID << endl;` for immediate result. – Didier Trosset Jun 26 '13 at 07:56
  • @TiroSagacious You should really try to understand what you are coding instead of copy-pasting something that doesn't make any sense. `outFile` is a `ofstream` type variable, and I imagine that `VUID` is also some type of variable - so what happens in C++ if you write 2 variable names next to each other? – Joum Jun 26 '13 at 07:58
2

It seems mistakenly it was added a ; at line 59

void storeFile();

Replace it with

void storeFile()
Alexandru Lache
  • 477
  • 2
  • 14
1

And probably delete the one on line 79 too.