delorie.com/archives/browse.cgi | search |
X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f |
Message-ID: | <20040903112112.2073.qmail@web20227.mail.yahoo.com> |
Date: | Fri, 3 Sep 2004 04:21:12 -0700 (PDT) |
From: | pradyut bhattacharya <pradyut100 AT yahoo DOT com> |
Subject: | file I/O |
To: | prgc AT yahoogroups DOT com, djgpp AT delorie DOT com |
MIME-Version: | 1.0 |
i have written a small file on object I/O. the code ---------------------------------------------- #include <iostream> #include <fstream> class student { private: int Regno; char cName[20]; public: void setRegno() { cout<<”Enter the registration number: “; cin >>Regno; } void setName() { cout <<”\nEnter the name of the student: “; cin >>cname; } int getRegno() { return Regno; } char *getName() { return cName; } }; int main() { ofstream sfil(“studfile.dat”); char ch; student svar; svar.setRegno(); svar.setName(); sfil <<svar.getRegno() <<” “ <<svar.getName(); sfil.close(); cout <<”\n Do you want to read the contents of the file(y/n)? “; cin >>ch; if (ch == ‘y’) { ifstream sfil(“studfile.dat”); char iregno; char nam[20]; sfil >>iregno >>nam; cout <<” \n Registration number is: “ <<iregno; cout <<”\n Student name is: “<<nam; } } --------------------------------------------------- on djgpp compiler it gives the error ------------------------------------------------ file.cc:12: error: stray '\148' in program file.cc:12: error: stray '\147' in program file.cc:17: error: stray '\148' in program file.cc:17: error: stray '\' in program file.cc:17: error: stray '\147' in program file.cc: In member function `void student::setRegno()': file.cc:12: error: `cout' undeclared (first use this function) file.cc:12: error: (Each undeclared identifier is reported only once for each fu nction it appears in.) file.cc:12: error: `Enter' undeclared (first use this function) file.cc:12: error: expected `;' before "the" file.cc:13: error: `cin' undeclared (first use this function) file.cc: In member function `void student::setName()': file.cc:17: error: `cout' undeclared (first use this function) file.cc:17: error: `nEnter' undeclared (first use this function) file.cc:17: error: expected `;' before "the" file.cc:18: error: `cin' undeclared (first use this function) file.cc:18: error: `cname' undeclared (first use this function) file.cc: In function `int main()': file.cc:32: error: `ofstream' undeclared (first use this function) file.cc:32: error: expected `;' before "sfil" file.cc:32: error: stray '\147' in program file.cc:32: error: stray '\148' in program file.cc:37: error: `sfil' undeclared (first use this function) file.cc:37: error: stray '\148' in program file.cc:37: error: stray '\147' in program file.cc:37: error: expected primary-expression before '<<' token file.cc:39: error: `cout' undeclared (first use this function) file.cc:39: error: stray '\148' in program file.cc:39: error: stray '\' in program file.cc:39: error: `n' undeclared (first use this function) file.cc:39: error: expected `;' before "Do" file.cc:39: error: stray '\147' in program file.cc:40: error: `cin' undeclared (first use this function) file.cc:41: error: stray '\145' in program file.cc:41: error: stray '\146' in program file.cc:41: error: `y' undeclared (first use this function) file.cc:43: error: `ifstream' undeclared (first use this function) file.cc:43: error: expected `;' before "sfil" file.cc:43: error: stray '\147' in program file.cc:43: error: stray '\148' in program file.cc:47: error: stray '\148' in program file.cc:47: error: stray '\' in program file.cc:47: error: expected `;' before "Registration" file.cc:47: error: stray '\147' in program file.cc:48: error: stray '\148' in program file.cc:48: error: stray '\' in program file.cc:48: error: expected `;' before "Student" file.cc:48: error: stray '\147' in program __________________________________ Do you Yahoo!? Yahoo! Mail is new and improved - Check it out! http://promotions.yahoo.com/new_mail
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |