Thread: return makes integer from pointer without cast

  1. #1
    Musicman - Canora
    Join Date
    Aug 2005

    return makes integer from pointer without cast

    im getting a cast error im not sure why im doin everthing correct i think? any idea's?

    char guessType()
      char type;
      char *prompt = "Enter the type  !\n";
       type = getUserInput(prompt);
       guessType=strtod = (type, NULL);
      return type;
    char* getUserInput(char *prompt)
       /* declaration of variables*/
       char *result;
       char buff[BUFF_SIZE];
       /* printing a char pointer*/
       /* whatever the user has typed in*/
       result = fgets(buff, BUFF_SIZE, stdin);
       /* if the user types in nothing it shows an error*/
        if(result == NULL)
            printf("Error please enter the input again!\n");
        else if(result[strlen(result)-1] != '\n')
        /* check if its used the whole buffer if so flush*/
        return result;

  2. #2
    Mad OnionKnight's Avatar
    Join Date
    Jan 2005
    Umeň, Sweden
    type should be char* instead of char.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > guessType=strtod = (type, NULL);
    Try pressing compile after every line you type.
    The range of mistakes you come out with, even after all this time is truly remarkable.

    strtod() is a function, you can't assign anything to it.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 03-10-2009, 10:29 AM
  2. Link List math
    By t014y in forum C Programming
    Replies: 17
    Last Post: 02-20-2009, 06:55 PM
  3. Pong is completed!!!
    By Shamino in forum Game Programming
    Replies: 11
    Last Post: 05-26-2005, 10:50 AM
  4. Request for comments
    By Prelude in forum A Brief History of
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  5. Replies: 3
    Last Post: 01-14-2002, 12:13 PM