Pointer / Integer error

This is a discussion on Pointer / Integer error within the C Programming forums, part of the General Programming Boards category; Hi, I am trying to get my head around a warning, I have searched about but found no examples that ...

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

    Pointer / Integer error

    Hi,

    I am trying to get my head around a warning, I have searched about but found no examples that are similar to my case.
    The warning I get on compiling is;
    assignment makes pointer from integer without a cast

    Code:
        int len;
        char temp[15];
        char *ptr;
    
    get string off user
    
        strcpy(pass,ptr); <-- this is the line generating the warning
    I assume I have done something silly somewhere here?

  2. #2
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,047
    what is the type of pass?

  3. #3
    Registered User
    Join Date
    Mar 2005
    Posts
    24
    oh sorry, pass should be temp. I have been cutting and pasting around to try and figure out what the error was complaining about.

    Code:
     
        int len;
        char temp[15];
        char *ptr;
    
    get string off user
    
        strcpy(temp,ptr); <-- this is the line generating the warning

  4. #4
    Registered User
    Join Date
    Jan 2008
    Posts
    28
    how are you 'getting the string' from the user?

  5. #5
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,794
    That shouldn't be the line causing the problem you reported. Something is being assigned to ptr improperly before that... probably in that "get string off user" part that you skipped over. We need to see that bit of code.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  6. #6
    Registered User
    Join Date
    Feb 2010
    Posts
    7
    It seems like "ptr" is not assigned properly. Please check its assignment.

  7. #7
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,452
    Just to make sure... did you include string.h?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling C in Visual Studio 2005
    By emanresu in forum C Programming
    Replies: 3
    Last Post: 11-16-2009, 03:25 AM
  2. what am I missing? (Program won't compile)
    By steals10304 in forum C Programming
    Replies: 3
    Last Post: 08-25-2009, 03:01 PM
  3. Replies: 0
    Last Post: 03-20-2008, 07:59 AM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  5. C++ compilation issues
    By Rupan in forum C++ Programming
    Replies: 1
    Last Post: 08-22-2005, 05:45 AM

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