Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #7195

Re: reading from a temp file

From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c++
Subject Re: reading from a temp file
Date 2011-06-28 20:37 +1200
Message-ID <96ti78FuacU2@mid.individual.net> (permalink)
References <iuc3me$nam$2@reader1.panix.com>

Show all headers | View raw


On 06/28/11 08:34 PM, Ruben Safir wrote:
> any clue why this isn't retrieving the contents of the temp file
>
>
> Question Deck::create_question(WINDOW* menu_win, std::ostream&os ,std::istream&in ){
>
>        char default_editor[20000] = "vi ";
>        char * editor;
>        char tmp[4096];
>        char path[] = "/tmp/fileXXXXXX";

Why don't you use strings?

>        int fd;
>        fd = mkstemp(path);
>        editor = getenv("EDITOR");
>        if (editor == NULL){
> 	 editor  = default_editor;
>        }
>
>        strcat(editor, path);
>        char quest_prompt[] = "Edit Your Question";
> .....
>        std::string input_q, input_a;
>        while( ( c=wgetch(quest_win) ) ){
> 	 if ( (c == 10) ){
> 	    def_prog_mode();
> 	    endwin();

What are these?

> 	    system(editor);
> 	    reset_prog_mode();

and this?

> 	     __gnu_cxx::stdio_filebuf<  char>   tmpfile_buf(fd, std::ios::binary|std::ios::app);

What's one of those?

> 	     std::istream is(&tmpfile_buf);
> 	     is.seekg(0, std::ios::beg);
> 	     while(is){
> 		is.read( tmp, 4096);
> 		std::cerr<<  "What did we read"<<  tmp<<  std::endl;
> 		input_q = tmp;
> 	     }
> 	     tmpfile_buf.close();
> 	     break;
> 	 }
>        }
>        remove(path);
>


-- 
Ian Collins

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

reading from a temp file Ruben Safir <ruben@mrbrklyn.com> - 2011-06-28 08:34 +0000
  Re: reading from a temp file Ian Collins <ian-news@hotmail.com> - 2011-06-28 20:37 +1200
    Re: reading from a temp file jt@toerring.de (Jens Thoms Toerring) - 2011-06-28 09:55 +0000
      Re: reading from a temp file Ruben Safir <ruben@mrbrklyn.com> - 2011-06-28 12:32 +0000
        Re: reading from a temp file jt@toerring.de (Jens Thoms Toerring) - 2011-06-28 13:54 +0000
          Re: reading from a temp file Ruben Safir <mrbrklyn@panix.com> - 2011-07-01 05:14 +0000
        Re: reading from a temp file Michael DOUBEZ <michael.doubez@free.fr> - 2011-07-01 00:54 -0700
    Re: reading from a temp file Michael DOUBEZ <michael.doubez@free.fr> - 2011-07-01 01:20 -0700
      Re: reading from a temp file Ruben Safir <mrbrklyn@panix.com> - 2011-07-02 00:47 +0000

csiph-web