The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Using sed buffer burakkilic Shell Programming and Scripting 1 12-14-2007 01:35 PM
Why is my buffer empty in vi? cookiebooy UNIX for Dummies Questions & Answers 2 10-28-2007 02:17 PM
Buffer IO error raybakh Linux 2 10-03-2006 06:41 PM
buffer the output collins High Level Programming 6 11-08-2004 11:57 PM
About Buffer Niko UNIX for Advanced & Expert Users 1 09-18-2001 12:49 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 06-15-2008
Registered User
 

Join Date: Sep 2007
Posts: 1
problem with steam buffer

Hello experts,

i have one query which i am not able to solve please suggest me my problem is i have to open a filedescriptor and have to store the contents in streambuffer,

i,e

Code:
Code:
int main () {

 char ch;
 streambuf * pbuf;size_t size;
  ifstream istr(const char *)fd);
  pbuf = istr.rdbuf();

  while (pbuf->sgetc()!=EOF)
  {
     ch = pbuf->sbumpc();
     cout << ch;
  }

  istr.close();

  return 0;
}
but here the line

Code:
Code:
ifstream istr(const char *)fd);
is not properly interpreting thats why there is no out put

if i simply give

Code:
Code:
ifstream istr(fd);
it gives me error as this method does not exist,
please helop me what to do but i want the result in streambuffer because this is the input for some other module in my project pleasesuggest what are the different way i can get so the i get the contents in streambuffer
thanks in advance
Reply With Quote
Forum Sponsor
  #2  
Old 06-18-2008
Registered User
 

Join Date: Jun 2008
Location: Scotland
Posts: 121
Code:
ifstream istr(const char *)fd);
Surely this shouldn't even compile?
You have unbalanced parentheses and fd has not been declared.
A std::ifstream can be constructed by giving it the name of the file from which to read as a const char*, e.g.
Code:
ifstream istr("filename");
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:17 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0