Thread: Maybe A Cast Problem?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Me
    Join Date
    Jul 2006
    Posts
    71

    Maybe A Cast Problem?

    Ok I have this code, which I want it convert the string answer into all lowercase letters. I'm using strlwr which you have to use a character array, but when I try to use a character array, it can't be a string(obviously) but when I check if it equals "roll" it doesn't work.

    Anyway, i'm not too sure about how to use a cast in this situation, and I would rather not have to, but if it is the only way to get around this, I guess it will have to do.

    Code:
    int main()
    {
    srand(time(NULL));
    string answer;
    
    do
    {
    cout<<"Enter A Command";
      cin>>answer;
      cin.ignore();
    
    strlwr(answer);
    
     if(answer=="roll")
      {
         roll_dice();
      }
    
    }
    while(1);
    
    cin.get();
    return 1;
    }

    Whoops. Forgot the error it gives me.

    Code:
    cannot convert `answer' from type `string' to type `char *'
    Last edited by relyt_123; 07-29-2006 at 05:22 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  2. Converting Double to Float
    By thetinman in forum C++ Programming
    Replies: 7
    Last Post: 06-17-2006, 02:46 PM
  3. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  4. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM
  5. Microsoft Visual C++ compiler, cast problem?
    By jonnie75 in forum C Programming
    Replies: 5
    Last Post: 11-10-2001, 08:53 AM