|
-
May 31st, 2000, 09:15 AM
#1
Ok, im using Borlands Turbo C and im new. What kind of line do i put in to let the keyboard input a string?
-
May 31st, 2000, 12:47 PM
#2
Addicted Member
C Strings
I sent you a mail attatchment with a small program in it.
Jeremy
-
May 31st, 2000, 12:48 PM
#3
You can't get a string,persay,from the command line.
What you can get is a character array, so,
do the following
char buffer[256]; //or however long you expect input to be
cout << "Enter something..";
cin >> buffer;
cout << buffer;
cout.flush();
/*
do whatever else you need to do
*/
As far as the string is concerned you can #include<cstring.h>
and then use
string buffer;
and use something like buffer.length() and buffer.get_at(3)
and so on.
If you use the string object you can't do
cout << buffer;
or cin >> buffer;
unless you convert the buffer variable to a cstring,
check your documentation for details.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|