Mailinglist Archive: opensuse-programming (33 mails)
| < Previous | Next > |
Re: [suse-programming-e] reading a file and display its content with cout
- From: Prabu Subroto <prabusubroto@xxxxxxxxx>
- Date: Mon, 31 Jan 2005 07:00:03 -0800 (PST)
- Message-id: <20050131150004.77338.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
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?
Thank you very much for your generousity.
--- Alan Lenton <alan@xxxxxxxxxxx> wrote:
> Prabu Subroto wrote:
> > Dear my friend.
> >
> > I want to make a linux server administrating tool
> ( I
> > am also a beginner in GNU C++).
> >
> > if I open the file (smb.conf) with ifstream and
> try to
> > display its content with cout, but it does not
> display
> > its content only somewhat looksline only an
> address of
> > the variable in the memory.
> > like this:
> > "
> > psubroto@vh64:~/arsip/proyek/g++/BLiSS> ./liss
> > Choose the server you would like to administrate :
> > 1. Samba Server
> > 1
> > Samba Server Administrating Menu
> > --------------------------------
> >
> > Workgroup name :bitp
> > nama workgroup-nya : bitp
> > 0xbfffef64
> > psubroto@vh64:~/arsip/proyek/g++/BLiSS>
> > "
> >
> > what is my mistake?
> [snip...]
>
> > void bsamba::menu(){
> > cout << "Samba Server Administrating Menu\n";
> > cout << "--------------------------------\n"
> <<
> > endl;
> > cout << "Workgroup name :";
> > cin >> bwg;
> >
> > cout << "nama workgroup-nya : " << bwg <<
> endl;
> > fstream sumber("smb.conf");
> > if (!sumber){
> > cout << "Failed in opening the 'smb.conf'
> > file\n";
> > exit(1);
> > }
> > cout << sumber << endl;
> > }
>
> [snip...]
>
> What you have asked it to print out is not the file,
> but the address of
> the stream. You need to use the stream (sumber) to
> read the file into a
> buffer and then write the buffer out to cout :)
>
> alan
>
__________________________________
Do you Yahoo!?
Yahoo! Mail - Find what you need with new enhanced search.
http://info.mail.yahoo.com/mail_250
"
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?
Thank you very much for your generousity.
--- Alan Lenton <alan@xxxxxxxxxxx> wrote:
> Prabu Subroto wrote:
> > Dear my friend.
> >
> > I want to make a linux server administrating tool
> ( I
> > am also a beginner in GNU C++).
> >
> > if I open the file (smb.conf) with ifstream and
> try to
> > display its content with cout, but it does not
> display
> > its content only somewhat looksline only an
> address of
> > the variable in the memory.
> > like this:
> > "
> > psubroto@vh64:~/arsip/proyek/g++/BLiSS> ./liss
> > Choose the server you would like to administrate :
> > 1. Samba Server
> > 1
> > Samba Server Administrating Menu
> > --------------------------------
> >
> > Workgroup name :bitp
> > nama workgroup-nya : bitp
> > 0xbfffef64
> > psubroto@vh64:~/arsip/proyek/g++/BLiSS>
> > "
> >
> > what is my mistake?
> [snip...]
>
> > void bsamba::menu(){
> > cout << "Samba Server Administrating Menu\n";
> > cout << "--------------------------------\n"
> <<
> > endl;
> > cout << "Workgroup name :";
> > cin >> bwg;
> >
> > cout << "nama workgroup-nya : " << bwg <<
> endl;
> > fstream sumber("smb.conf");
> > if (!sumber){
> > cout << "Failed in opening the 'smb.conf'
> > file\n";
> > exit(1);
> > }
> > cout << sumber << endl;
> > }
>
> [snip...]
>
> What you have asked it to print out is not the file,
> but the address of
> the stream. You need to use the stream (sumber) to
> read the file into a
> buffer and then write the buffer out to cout :)
>
> alan
>
__________________________________
Do you Yahoo!?
Yahoo! Mail - Find what you need with new enhanced search.
http://info.mail.yahoo.com/mail_250
| < Previous | Next > |