Converting Hex to Decimal (strtol) not working?

This is a discussion on Converting Hex to Decimal (strtol) not working? within the C Programming forums, part of the General Programming Boards category; I am getting an error during the calculation of "n"?? For the; Code: n=(int*)Posn; and n=(int *)Posn; I am seeing ...

  1. #16
    Registered User
    Join Date
    Apr 2012
    Posts
    14
    I am getting an error during the calculation of "n"?? For the;

    Code:
    n=(int*)Posn;
    
    and
    
    n=(int *)Posn;

    I am seeing an error "a value of type "int *" cannot be assigned to an entity of type "int" ?? Any ideas?

  2. #17
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    n is an int, so obviously you can't assign an int* to it. You might try n = *(int*)Posn, but as has already been pointed out, there may be alignment problems since, for example, a 4-byte int often needs to begin on a 4-byte boundary, whereas a char array could possibly begin anywhere. You could try the enum idea to ensure proper alignment.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting decimal to binary
    By BrandNewDeipz in forum C Programming
    Replies: 4
    Last Post: 03-03-2012, 08:34 AM
  2. Converting Decimal to Binary
    By BeldenML in forum C Programming
    Replies: 17
    Last Post: 02-09-2012, 10:29 AM
  3. Converting decimal to binary
    By ubernos in forum C Programming
    Replies: 3
    Last Post: 12-06-2005, 09:09 AM
  4. Converting decimal to hex
    By cobrakidd in forum C++ Programming
    Replies: 9
    Last Post: 02-06-2003, 10:37 AM
  5. converting a hex number to decimal???
    By Unregistered in forum Game Programming
    Replies: 8
    Last Post: 04-13-2002, 05:46 PM

Tags for this Thread


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