View Single Post
Old 09-21-07, 05:09 AM   #6
Registered User
Join Date: Nov 2003
Posts: 14
Default Re: C++ Gurus, School Me :D

Hi six_storm

The problems with that code is that it isn't indented properly. That always ruins everything.

Always check all your statements are terminated (;'s) and that all your functions have a return type specified.

You also need to watch out for namespaces. Everything in the standard c++ libraries is in the std namespace. To use something from a namespace you just scope it by going std::ifstream for example.

The below code is syntactically ok (well, it compiles at least) but all you have is an uninitialized array big enough to hold 60 pointers...where does the data streamed from the inFile go?

#include <fstream>

struct myStruct
   char *name[60];

int main()
   int x=0;
   myStruct mainStruct;
   std::ifstream inFile;"input.txt");

      inFile >>[x];

   return 0;
picofarad is offline   Reply With Quote