do you mean like this: " char mybuffer[]; fstream sumber("smb.conf"); if (!sumber){ cout << "Failed in opening the 'smb.conf' file\n"; exit(1); } sumber >> mybuffer; cout << mybuffer << endl; "?
Please tell me more details. Could you give me a very simple sample? yes, but you are not allocating space for mybuffer. You must declare a size. In the case below, I create a file, test.dat, but you could use smb.conf Nore that the >> operator reads a word. If you want to read a line, use the getline() member function. Here is an example, below. #include <iostream> #include <fstream> using std::cin; using std::cout; using std::cerr; using std::fstream; using std::endl; using std::ios;
On Monday 31 January 2005 10:00, Prabu Subroto wrote:
main ()
{
fstream file1;
char mybuffer[512];
file1.open( "/etc/samba/smb.conf", ios::in);
if (!file1)
{
cerr << "Unable to open test.dat." << endl;
exit(1);
}
while( !file1.eof() ) {
file1.getline(mybuffer, sizeof(mybuffer));
cout << mybuffer << endl;
}
file1.close();
}
--
Jerry Feldman