struct,line of of characters

This is a discussion on struct,line of of characters within the C Programming forums, part of the General Programming Boards category; I was like trying to create a program,to edit and modify text . So I created 2 linked lists, one ...

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    58

    struct,line of of characters

    I was like trying to create a program,to edit and modify text .
    So I created 2 linked lists, one for the characters and one for the lines.

    the program i created was :
    Code:
     #include <stdio.h>
    
    typedef struct node{
        char cHar;
        struct node *next;
    }character;
    
    typedef struct sentence{
        character word;
        struct sentence *next;
    }line;
    
    
    int main(void){
        
        character *d;
        line *e;
        
        e->word.cHar='d';
        
        e->word=e->word.next;
        e->word.cHar='a';
        
        e->word=e->word.next;
        e->word.cHar='v';
        
        e->word=e->word.next;
        e->word.cHar='i';
        
        e->word=e->word.next;
        e->word.cHar='d';
        
        
    }
    but it doesn't work.Can some one help as to how to go on add the 2nd character and how to manually assign it some some letter.

    And also how to allocate some memory space for the new letter.
    All replies posted to this thread is much appreciated.
    Thanks Alot

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You're just throwing stuff out in random spots in memory. You can't do that. Well you can, it's just wrong, and will likely crash your program. Look up things like malloc and free.


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 11:39 PM
  2. HELP!!!!emergency ~expert please help
    By unknowppl in forum C Programming
    Replies: 1
    Last Post: 08-19-2008, 08:35 AM
  3. Replies: 10
    Last Post: 07-10-2008, 04:45 PM
  4. How do you check how many characters a user has entered?
    By engstudent363 in forum C Programming
    Replies: 5
    Last Post: 04-08-2008, 07:05 AM
  5. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 05:54 PM

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