problem with steam buffer


 
Thread Tools Search this Thread
Top Forums Programming problem with steam buffer
# 1  
Old 06-16-2008
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
# 2  
Old 06-18-2008
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");

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Web Development

Vue.js Steam Chat

This Vue.js chat component installed easily: npm i --save vue-steam-chat I was able to set it up and change the background color in the component css file to match the forums in seconds: https://www.unix.com/members/1-albums225-picture1162.png <template> <div style="height: 600px;... (17 Replies)
Discussion started by: Neo
17 Replies

2. Shell Programming and Scripting

Problem with GREP + CUT - script for automatic update of STEAM GAME AR

Hello, I have a problem with the /etc/rc.d/init.d script to automatically update STEAM GAME ARK. I've converted 3 scripts into one, but something does not work correctly ... The problem is in the file latestavailableupdate.txt / line 36/39. It think the problem is with script, it wrongly... (2 Replies)
Discussion started by: kshishu
2 Replies

3. Programming

buffer in C

Hello, size_t write(int fd, const void *buf, size_t count) { static size_t (*write_func)(int, const void *, size_t) = NULL; if (!write_func) write_func = (size_t(*)(int, const void *, size_t)) dlsym(RTLD_NEXT, "write"); char tmp; memcpy(tmp,buf,count); ... (3 Replies)
Discussion started by: chercheur857
3 Replies

4. UNIX for Dummies Questions & Answers

vi next buffer

Hello, I am using vi to edit file vi filea :e fileb and :e# to switch between filea and fileb Now, I'd like to have many files open at the same time and have a way to cycle between them. :bn does not work; when I type it, nothing happens... Is there something to add to the... (1 Reply)
Discussion started by: JCR
1 Replies

5. Shell Programming and Scripting

Problem with awk awk: program limit exceeded: sprintf buffer size=1020

Hi I have many problems with a script. I have a script that formats a text file but always prints the same error when i try to execute it The code is that: { if (NF==17){ print $0 }else{ fields=NF; all=$0; while... (2 Replies)
Discussion started by: fate
2 Replies

6. Shell Programming and Scripting

Using sed buffer

Hi. I have some questions about using sed. I cannot use the hold buffer. For example i want to put first line to the buffer than take second line and append the buffer to the second line.then 3th to the all. It will be like 2->1->3 th lines. Any idea? (1 Reply)
Discussion started by: burakkilic
1 Replies

7. UNIX for Dummies Questions & Answers

buffer question

Hi... I have a question about how many lines the window can remember... is there an environemtn varible for this I can change??? I'm not talking about how many previous commands it remembers. I am talking about how many lines it remembers and for how many lines I can press "page-up" and I can... (4 Replies)
Discussion started by: lmanchur.
4 Replies

8. Programming

buffer the output

Hai Friends I am writing a cgi program in C. The CGI program has a link to start my tcp chat server... The tcp chat server prints some information when it starts... I have captured the informations and sent to the client browser through the cgi program... But the output is displayed all... (6 Replies)
Discussion started by: collins
6 Replies

9. UNIX for Advanced & Expert Users

vm and buffer cache

i have a serious doubht about the assignment of memory in hp-ux system . i read from somewhere that the page allocation in hp-ux is not unified unlike compaq . i wanted to know in hp-ux kernel ,once the pages are assigned for the univarsal buffer cache... (2 Replies)
Discussion started by: vish_shan
2 Replies

10. UNIX for Advanced & Expert Users

About Buffer

Hi, if someone now how can look the last commands has used for last week? (1 Reply)
Discussion started by: Niko
1 Replies
Login or Register to Ask a Question