Thread: char converting and constants

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    3

    char converting and constants

    Could someone help me with this thing? I am trying to get an alphanumeric set of characters from the user while making sure that it is 10 characters in length. I keep getting errors saying that I " need an explicit cast for function parameter 1 to get from char ". I imagine that this has everything to do with using character constants. I can find no examples to enlighten me for what I am trying to do here. Please help.




    /////////////////

    char customer_chars[11];

    char ch;

    for(;;)
    {
    gets (ch);

    if(strlen(ch) == 10 && isalnum(ch))

    break; // leave loop to continue the program

    }


    //////////////

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Have you looked up gets, at all, even a little bit? gets doesn't take a single character, it takes a pointer to memory. There's also no way to tell gets to stop at 10 characters, which is (one reason) why you shouldn't use it. Is there a reason you don't want to use the standard C++ input operators (like >>)?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting an int to an address in an array
    By bommy in forum C Programming
    Replies: 16
    Last Post: 03-19-2009, 03:02 PM
  2. Converting data types
    By Kool4School in forum C++ Programming
    Replies: 6
    Last Post: 01-09-2009, 05:19 PM