> -----Original Message-----
> From: Ioannis Vranos [mailto:iv...@at...]=20
> Sent: Saturday, April 26, 2003 1:17 PM
> To: 'Dev-C++ Mailing List'
> Subject: RE: [Dev-C++] how to do a shell like input..
>=20
>=20
>=20
>=20
> > -----Original Message-----
> > From: dev...@li...=20
> > [mailto:dev...@li...] On Behalf=20
> > Of Christian Sch=E4fer
> > Sent: Saturday, April 26, 2003 10:29 AM
> > To: Dev-C++ Mailing List
> > Subject: [Dev-C++] how to do a shell like input..
> >=20
> >=20
> > hi Dev-C++,
> > [this is a followup thread to 'stdin reset..']
> >=20
> > I want to programm a shell-like interface for my=20
> application, in which
> > I know some special commands with options and arguments.
> >=20
> > the problem I have is, how do I create an input-buffer, that is able
> > to hold whatever is read from stdin, since i can not say=20
> what would be
> > the longest valid entry (say cat some large text...).
> >=20
> > is there a way to dynamically read the length of the=20
> inputstring up to
> > the first '\n' and then malloc some string and THEN scanf() ???
>=20
>=20
> You can use a temporary buffer in the automatic storage of a=20
> fixed size where you will store using getchar(), and then use=20
> malloc() and realloc() to allocate the necessary space on the=20
> free store and strcat() from the temp buffer... In C++ you=20
> would simply do:
>=20
>=20
> string s;
>=20
> while(cin>>s)
> ;
The above C++ thing would read only up to the first whitespace =
character. So
forget it anyway.
Ioannis Vranos
=20
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL 1: http://run.to/noicys
* Alternative URL 2: http://www.noicys.cjb.net
Anti-racism movement: http://www.positive-youthfoundation.org
Iraq Peace Pledge: http://www.peacepledge.org
|