🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.comp.lang.learn.c-c++
Article #326

newbie: strings versus char*

#326
From: tagus18
Date: Mon, 27 Dec 1999 00:00
44 lines
2393 bytes
Hi.

[I have read two online c++ tutorials and found at least three usenet
threads concerning this issue, but I am still unable to solve this
problem. Therefore, please forgive me for bringing up this issue
again... I have read the c++ faq-lite, too :-)...)

I am using turbo c++ 3.0 for DOS. (I know it is old but I suppose that
it should be possible to do this sort of things.)

I want to prompt the user for input and allow her to type as much as he
wants to (and afterwards store the inputed text in a string / char*).

Following the advice given to previous posters, I tried to include
string.h and create a string object of undefined length. But none of
the three constructors which are available do this: the first creates a
string of predefined length (it is passed as an argument to the
constructor), the second converts a null-terminated C-string to a
"string" object of this class and the third is a copy constructor.

Previously I had tried to create an array of characters in the free
store and use cin:

char* text = "";
cin >> text;

This allowed the user to enter 127 characters(if I am not mistaken),
but then the computer just beeped (I suppose that the keyboard was
full!). The inserted characters were stored correctly, it seems, in the
array "text". What can I do? I suppose that increasing the size of the
keyboard buffer isn't the solution, because that would imply setting a
maximum value again.

Thank you very much for your attention and please forgive the length of
this message... no array of chars could ever handle this :-) !

Bye,

Maria van Brooedk



Sent via Deja.com http://www.deja.com/
Before you buy.
Technical Details
Message-ID: <8485tm$cfg$1@nnrp1.deja.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1061d2,fcdf60e52711dfec,start
X-Google-Attributes: gid1061d2,public
X-Google-Thread: 114592,fcdf60e52711dfec,start
X-Google-Attributes: gid114592,public
From: tagus18@my-deja.com
Subject: newbie: strings versus char*
Date: 1999/12/27
Message-ID: <8485tm$cfg$1@nnrp1.deja.com>
X-Deja-AN: 565340163
X-Http-Proxy: 1.1 x23.deja.com:80 (Squid/1.1.22) for client 195.23.240.229
Organization: Deja.com - Before you buy.
X-Article-Creation-Date: Mon Dec 27 17:05:23 1999 GMT
X-MyDeja-Info: XMYDJUIDtagus18
Newsgroups: alt.comp.lang.learn.c-c++,borland.public.cpp.non-technical
X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)