Thread: What is the issue?

  1. #1
    Registered User
    Join Date
    Dec 2006
    Location
    TX
    Posts
    19

    What is the issue?

    I have been looking this over for way to long now. I know that the problem must be simple, but I just don't see it. I am getting two big warnings that I know need to be addressed before the program will actually work, but I am to new to recognize the issue. The warnings are
    c:8: warning: assignment makes integer from pointer without a cast
    c:10: warning: passing arg 1 of `display' makes pointer from integer without a cast

    and of course the code is
    Code:
    #include <stdio.h>
    int display (int*);
    
    int main()
    {
    int channel[7];
    int *cptr;
    channel[7]="2,4,5,7,9,11,13";
    cptr = channel;
    display (*cptr);
    
    return 0;
    }
    
    int display (int *cptr)
    {
    int i;
    for (i=0; i<=6; ++i)
    printf ("\nElement %d is %d", i,*(cptr + i));
    
    system ("Pause");
    
    return 0;
    }
    Any help, no matter how critical is appreciated. Please give me a small explination with it so I don't have this again in the future. Thanks.

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    display (cptr);
    not display (*cptr);

    or rather
    display (channel);
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    And
    Code:
    int channel[7] = {2,4,5,7,9,11,13};
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Some weird issue.
    By dbzx in forum C Programming
    Replies: 7
    Last Post: 04-12-2009, 04:10 PM
  2. float calculation issue
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 05-26-2008, 04:56 AM
  3. type safe issue
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 02-12-2008, 09:32 PM
  4. Replies: 8
    Last Post: 01-17-2006, 05:39 PM
  5. my first issue of GDM
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 09-12-2002, 04:02 PM