assignment makes int from pointer w/o cast

This is a discussion on assignment makes int from pointer w/o cast within the C Programming forums, part of the General Programming Boards category; i am getting a warning: assignment makes integer from pointer without a cast i am compiling with gcc on slackware ...

  1. #1
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385

    assignment makes int from pointer w/o cast

    i am getting a warning:
    assignment makes integer from pointer without a cast

    i am compiling with gcc on slackware 10 but its a general language question which is why its not posted to linux programming.

    this is the function that is generating the error

    Code:
    void clearPacketArray(void)
    {
      int i;
      for (i=0; i <= MAXPACKETLEN; i++) 
            {
                packet[i] = NULL;
             }
    }
    packet is a globally declared char array of size MAXPACKETLEN
    which is declared as follows at the top of the program
    Code:
    #define MAXPACKETLEN 256
    i have tried changing it to
    packet[i] = "";
    and
    packet[i] = '';

    all result in the same warning which i would like to rid from my program
    Monday - what a way to spend a seventh of your life

  2. #2
    not-a-geek
    Join Date
    Apr 2004
    Posts
    210
    Quote Originally Posted by iain
    packet is a globally declared char array of size MAXPACKETLEN
    You mean like char packet[MAXPACKETLEN] ?
    If so, try

    Code:
    packet[i] = '\0';
    main() { int O[!0<<~-!0]; (!0<<!0)[O]+= ~0 +~(!0|!0<<!0); printf("a function calling "); }

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,855
    NULL is a pointer
    '\0' is the nul character (which you want)

  4. #4
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Code:
      for (i=0; i <= MAXPACKETLEN; i++)
    Are you sure about that?
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  5. #5
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385
    setting it to '/0' remedied the error

    for (i=0; i <= MAXPACKETLEN; i++)
    ahh yeah, that was silly - thanks for pointing that out
    Monday - what a way to spend a seventh of your life

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sorting number
    By Leslie in forum C Programming
    Replies: 8
    Last Post: 05-20-2009, 05:23 AM
  2. NEED HELP READING FILE and PRINTING
    By geoffr0 in forum C Programming
    Replies: 4
    Last Post: 04-16-2009, 06:26 PM
  3. memory leak
    By aruna1 in forum C++ Programming
    Replies: 3
    Last Post: 08-17-2008, 11:28 PM
  4. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03:39 PM
  5. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM

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