public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* several question of standard C++
@ 2001-04-17  1:41 liujg
  2001-04-17 14:47 ` Alexandre Oliva
  0 siblings, 1 reply; 2+ messages in thread
From: liujg @ 2001-04-17  1:41 UTC (permalink / raw)
  To: gcc-help

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1031 bytes --]





Sir:
1.With ANSI C,which function can be used to change file size 
similar to chsize() with VC++?
2.For console program,How do I check keystroke before it 
appears on screen and decide whether show it or not by myself.
3.I want to produce a strstream in memory which consist of 
three parts,the first is preamble which length is 10 bytes include following the 
length value of 2 indivuals,last two parts both are data.First,I assume the 
value of the length of data be 0.After inserting those three parts sequently,I 
get the length of data and set it to preamble in the first parts.I do it 
so:

/*assume the length of whole data block is 328bytes*/
os.seekp(4,ios::beg);//address to buffer of length
os<<len1<<len2;//fill with real value of length of 2 data 
parts
/*problem occurs!!! I don't know how to explain it!*/
os.seekp(328,ios::beg);//want to the end of strstream
r = os.tellp();//r is 10 os.seekp(0,ios::end);//rdstate() 
return badbit(4) r = os.tellp();//r is 301
Best regards.
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: several question of standard C++
  2001-04-17  1:41 several question of standard C++ liujg
@ 2001-04-17 14:47 ` Alexandre Oliva
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Oliva @ 2001-04-17 14:47 UTC (permalink / raw)
  To: liujg; +Cc: gcc-help

On Apr 17, 2001, "liujg" <liu.jianguo@prosperity.com.cn> wrote:

> 1.With ANSI C,which function can be used to change file size similar to chsize() with VC++?

truncate().  I'm not sure it's ANSI, but it's quite common.

> 2.For console program,How do I check keystroke before it appears on
> screen and decide whether show it or not by myself.

You can put the terminal in non-echo mode and disable line-buffering.
Using a library named `curses', `ncurses' or perhaps `termcap' is
probably the easiest way to do it.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-04-17 14:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-17  1:41 several question of standard C++ liujg
2001-04-17 14:47 ` Alexandre Oliva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).