Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Ian Collins Newsgroups: comp.lang.c++ Subject: Re: reading from a temp file Date: Tue, 28 Jun 2011 20:37:32 +1200 Lines: 57 Message-ID: <96ti78FuacU2@mid.individual.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net JM9ZBnkoCLl+wRcWEd/e7gazbqSe2Ujc9NbkXTUaJiOzyxVvRz Cancel-Lock: sha1:RkvEyBjQoYQIu17nNNTCtz4LH1c= User-Agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.2.9) Gecko/20101021 Lightning/1.0b2 Thunderbird/3.1.4 In-Reply-To: Xref: x330-a1.tempe.blueboxinc.net comp.lang.c++:7195 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