🔒 Locked
sorry..string problem continues
Advertisement
Original Post
ok disregard my last post for now...
my real goal is to work on an AI bot program, basically a simple console program that lets you talk to an AI bot.
my problem is, i want the user to be able to say anything he or she wants to. so i don''t want my input string to have a fixed length because you won''t know what the user will be typing in.
so how should i go about doing this? what kind of variable, how should i input it, etc?
also i cant seem to get to store strings with spaces in them..
for instance, typing "hello my name is bob" only seems to store "hello" in the string.
this is my coding right now
that coding seems to properly store my spaces, but i have to hit enter twice for this to work. is there any way to do what i'm trying to do w/o all this crap, heh.
Edited by - Stashi on November 18, 2001 1:31:20 PM
for instance, typing "hello my name is bob" only seems to store "hello" in the string.
this is my coding right now
|
that coding seems to properly store my spaces, but i have to hit enter twice for this to work. is there any way to do what i'm trying to do w/o all this crap, heh.
Edited by - Stashi on November 18, 2001 1:31:20 PM
instead of using a string use an array of chars ie: char str[];
just don''t specify a length so you could go
cout << "ENTER STRING";
cin >> str;
to view the string then just go:
cout << str;
strings suck don''t use em unless you have something set to say but otherwise use arrays of chars.
just don''t specify a length so you could go
cout << "ENTER STRING";
cin >> str;
to view the string then just go:
cout << str;
strings suck don''t use em unless you have something set to say but otherwise use arrays of chars.
alco, your coding of
gives me the error..
Compiling...
main.cpp
c:\microsoft visual studio\myprojects\str\main.cpp(4) : error C2133: ''str'' : unknown size
Error executing cl.exe.
str.exe - 1 error(s), 0 warning(s)
|
gives me the error..
Compiling...
main.cpp
c:\microsoft visual studio\myprojects\str\main.cpp(4) : error C2133: ''str'' : unknown size
Error executing cl.exe.
str.exe - 1 error(s), 0 warning(s)
http://support.microsoft.com/support/kb/articles/q240/0/15.asp?LN=EN-US&SD=g
This will explaian why your original code didn''t work properly.
This will explaian why your original code didn''t work properly.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement