return makes integer from pointer without cast

This is a discussion on return makes integer from pointer without cast within the C Programming forums, part of the General Programming Boards category; im getting a cast error im not sure why im doin everthing correct i think? any idea's? Code: char guessType() ...

  1. #1
    Musicman - Canora
    Join Date
    Aug 2005
    Location
    Melbourne
    Posts
    252

    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?


    Code:
    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*/
       printf(prompt);
       
       /* 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')
        {
            readRestOfLine();
        }
        /* check if its used the whole buffer if so flush*/
      
        return result;
       
       
    }

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

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,590
    > 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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 05: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 Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM
  5. Replies: 3
    Last Post: 01-14-2002, 11:13 AM

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