Code::Blocks has Alzheimer's: "casting" warning

This is a discussion on Code::Blocks has Alzheimer's: "casting" warning within the C Programming forums, part of the General Programming Boards category; Hello: I think my 'C' code is correct, but Code::Blocks warns with: "warning: cast from pointer to integer of different ...

  1. #1
    Registered User
    Join Date
    Jul 2012
    Location
    Eastern WA State
    Posts
    7

    Code::Blocks has Alzheimer's: "casting" warning

    Hello:

    I think my 'C' code is correct, but Code::Blocks warns with:

    "warning: cast from pointer to integer of different size"

    First, the data setups.

    Code:
    struct soughtstrings {
    char *sought_string;
    char sought_string_data[100];        /* typical string */
    int   bypass_sought_string;
    };
    
    struct programdata {
    int  some_int;
    long some_long;
    struct soughtstrings ss[50];      /* no big whoop here */
     };
    Inside function:

    Code:
    scan_strings()
    {
    int   i;
    struct programdata pd;      /* allocate the structure */
    ...
    ...
    ...
    for (i = 0; i < 49; i++)
      {
    
      pd.ss[i].sought_string_data[0] = (char) " ";    <<<WARNING HERE
    
      }
     }
    Since all this is at the scope of struct programdata, I see no need for pointer dereferencing. Warning again:

    warning: cast from pointer to integer of different size

    I don't see any "pointer to integer". Do you? Where? I simply want to insert a space in "sought_string_data[]" array position 0.

    Thanks!

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,269
    Quote Originally Posted by gandsnut
    I don't see any "pointer to integer". Do you? Where?
    I see an array of 2 chars: " ". An array can be converted to a pointer to its first element.

    Anyway, what you should write is:
    Code:
    pd.ss[i].sought_string_data[0] = ' ';
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Jul 2012
    Location
    Eastern WA State
    Posts
    7
    My bad. Good catch. I need new glasses.... Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 03-12-2011, 06:59 PM
  2. Replies: 9
    Last Post: 05-28-2010, 11:11 AM
  3. An interesting code about "struct" in "union"
    By meili100 in forum C++ Programming
    Replies: 3
    Last Post: 04-08-2008, 05:37 AM
  4. "itoa"-"_itoa" , "inp"-"_inp", Why some functions have "
    By L.O.K. in forum Windows Programming
    Replies: 5
    Last Post: 12-08-2002, 08:25 AM
  5. "CWnd"-"HWnd","CBitmap"-"HBitmap"...., What is mean by "
    By L.O.K. in forum Windows Programming
    Replies: 2
    Last Post: 12-04-2002, 07:59 AM

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