
-----------------------------------
endusto
Tue May 10, 2005 6:43 pm

how to get a string
-----------------------------------
im just starting and i have a program that will ask you for a number and then tell you the number you entered.  how would i make a string so i can enter a word or two instead of just numbers or 1 letter?


this is my code:

#include 

using namespace std;

int main() {
    int cat;
coutcat;
cin.ignore();
cout foo;

You now have a "word" (delimited by a space).

-----------------------------------
blackcat
Wed May 18, 2005 12:46 pm


-----------------------------------
int  is for numbers
so declare a string liek wtd said


so lets use

#include 
using namespace std;
int main ()
{
  string foo;  //* this is the variable fag
  cout > foo; //* get answer which is a string because string foo;
  cout 