Thread: My Pointer is broken....

  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
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    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, 08:23 PM
  5. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM