Can't Input an int....

This is a discussion on Can't Input an int.... within the C++ Programming forums, part of the General Programming Boards category; For some reason, I am having a really wierd problem with a program... It wont let me input an integer. ...

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    4

    Can't Input an int....

    For some reason, I am having a really wierd problem with a program... It wont let me input an integer. Its part of a function in a somewhat simple battleship game. Here is the start of that function:

    Code:
    void playerattack()
    {
        int hori;
        char vert, ship;
        bool hit;
        
        cout<<"Chose horizontal target (1-10): ";
        cin>>hori;
    
    ...
    It compiles fine, but when I put in that number it crashes... Any sugestions would be great.
    Last edited by qwertykeyboard; 03-29-2005 at 04:31 PM.

  2. #2
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    Post your whole code, what you have there seems to be fine unless you are entering in a character instead of a number.

  3. #3
    Registered User
    Join Date
    Mar 2005
    Posts
    4
    I'm going to try revising the whole thing first. A bunch of parts got quite messy, because at the end I was getting a bit overwhelmed. If I still have this problem afterwards I'll post the whole thing.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. About aes
    By gumit in forum C Programming
    Replies: 13
    Last Post: 10-24-2006, 03:42 PM
  2. Game Won't Compile
    By jothesmo in forum C++ Programming
    Replies: 2
    Last Post: 04-01-2006, 03:24 PM
  3. easy if you know how to use functions...
    By Unregistered in forum C Programming
    Replies: 7
    Last Post: 01-31-2002, 06:34 AM
  4. My graphics library
    By stupid_mutt in forum C Programming
    Replies: 3
    Last Post: 11-26-2001, 05:05 PM
  5. A Simple (?) Problem
    By Unregistered in forum C++ Programming
    Replies: 8
    Last Post: 10-12-2001, 04:28 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21