problem with streambuffer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vin029
    New Member
    • Nov 2007
    • 10

    problem with streambuffer

    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:
    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:
    ifstream istr(const char *)fd);
    is not properly interpreting thats why there is no out put

    if i simply give
    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 <b>streambuffer </b> 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 <b>streambuffer .</b>

    thanks in advance.
  • vin029
    New Member
    • Nov 2007
    • 10

    #2
    please experts help me

    even i tried in this way also

    Code:
    char ch[100];
    pFile = fdopen (fd,"r");
    fgets(ch, 90,pFile);
    know is there any way i can convert character buffer to stream buffer
    please tell me if any alternate solutions for this problem.

    at the end i want the output in streambuffer.

    Comment

    • Banfa
      Recognized Expert Expert
      • Feb 2006
      • 9067

      #3
      Originally posted by vin029
      Code:
      ifstream istr(const char *)fd);
      Count the ( and )

      Also have you tried using a stringstream defined in sstream?

      Comment

      Working...