My Pointer is broken....

This is a discussion on My Pointer is broken.... within the C Programming forums, part of the General Programming Boards category; well actually im doing a linked list in C and im having trouble inputing a string into my structure here ...

  1. #1
    Registered User Nexxuz's Avatar
    Join Date
    Sep 2003
    Posts
    2

    Question My Pointer is broken....

    well actually im doing a linked list in C and im having trouble inputing a string into my structure

    here is my code:
    Code:
    typedef struct
    {
    char *Name;
    float Price;
    struct MyItems * Next;
    }MyItems;

    this is how im inputting Name
    (Current is of type MyItems)

    Code:
    scanf("%s",Current->Name);


    this is how im outputting Name

    Code:
    printf("%s",Current->Name);

    i would really appreciate any help
    -thenexxuz

  2. #2
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    You should use a character array, not a character pointer to store the string.

  3. #3
    Registered User Nexxuz's Avatar
    Join Date
    Sep 2003
    Posts
    2
    thank you

    i cant belive i did that!!!
    -nexxuz

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 0
    Last Post: 03-20-2008, 07:59 AM
  2. Parameter passing with pointer to pointer
    By notsure in forum C++ Programming
    Replies: 15
    Last Post: 08-12-2006, 07:12 AM
  3. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM
  4. How did you master pointers?
    By Afrinux in forum C Programming
    Replies: 15
    Last Post: 01-17-2006, 07:23 PM
  5. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM

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