Warning for a pointer of structure

This is a discussion on Warning for a pointer of structure within the C Programming forums, part of the General Programming Boards category; Hey, so I have this here: Code: char *item; item=&fact[numero].transactions.items[k].noItem; 'noItem' is a char too. For some reason, the program ...

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    16

    Warning for a pointer of structure

    Hey, so I have this here:

    Code:
    char *item;
    
    item=&fact[numero].transactions.items[k].noItem;
    'noItem' is a char too. For some reason, the program is doing as expected, the good value is read into item, but I get this warning that 'assignment from incompatible pointer type'.

    Any idea why I got this warning? (it's not a big deal, but I'd like to fix it)

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    You must mean noItem is also a char pointer. Get rid of the address of operator (&).
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Registered User
    Join Date
    Nov 2008
    Posts
    16
    Wow thank you! So stupid mistake.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pointers, structures, and malloc
    By lugnut in forum C Programming
    Replies: 24
    Last Post: 10-09-2008, 04:52 PM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  3. Resource ICONs
    By gbaker in forum Windows Programming
    Replies: 4
    Last Post: 12-15-2003, 06:18 AM
  4. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM

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