C++/OOP
Expert: Prince M. Premnath - 11/23/2006
Questioncan u tel me the errors in the following statements..please
1.ifstream.infile("DATA");
2.infile.open(argc);
3.finout.open(file:ios::in|ios::out|ios::ate);
4.infile.open(argc);
hope for ue early reply...
Thanking You,
Rikin
AnswerDear Rikin!
1. In the first statement , ifstream is a class where as infile is an object associated with ifstream class( it will invoke the constructor for ifstream class in order to open a file in input mode !) so the statement should be used like this.
ifstream infile("DATA");
2. As we know very well in the command line argument the variable 'argc ' is as integer used to hold the number of arguments passed to main() , where as the member function
open() expects a string to open a file , not an integer !
3. The general format of 3rd statement is stream_object.open("filename" , mode);
so the given instruction finout.open(file:ios::in ....) should have to be corrected as
finout.open(file , ios::in|ios::out|ios::ate);
4.Refer 2nd point !
Regards !
Prince M. Premnath.
-Happy Programming !