Thread: linked list with char array HELP!

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    3

    linked list with char array HELP!

    i'm writing a basic linked list program, prompting to enter (among a lot of things) a description. everything is coming out right but somehow the description is getting lost before it can be outputted. i know i'm making a basic error here, so i'm hoping someone can tell me what i'm doing wrong. here's my code, edited for the description part:

    Code:
    struct
    {
        char descrip[25];
        node* next;
    };
    
    void InsertDescrip(char [] );
    node* head=NULL;
    
    int main()
    {
    char des[25];
    node* current=NULL;
         cout<<"Enter description:  "<<endl;
         cin>>des;
    
         current= new node;
         InsertDescrip(des);
         head=current;
    
         cout<<"Press any key to terminate"<<endl;
         getch();
    }
    
    void InsertDescrip(char des[25] )
    {
        current->descrip[25]=des[25];
        current->next=head;
    }
    Last edited by littlepiggy; 10-18-2005 at 02:43 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. newbie needs help with code
    By compudude86 in forum C Programming
    Replies: 6
    Last Post: 07-23-2006, 08:54 PM
  2. How to use Linked List?
    By MKashlev in forum C++ Programming
    Replies: 4
    Last Post: 08-06-2002, 07:11 AM
  3. 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
  4. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM