Click here to Skip to main content
15,920,513 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hey everyone,

I am trying ot make a link list for my program. My task is to take the input of characters and store that input into a link list. If the input is equal to "read" then any characters after read (until it reaches the return or space) will be stored into the variable name. This is the part i am having trouble with and it has to be done in a link list. Any help is appreciated. This is what i have so far. Thanks!

C++
if(input[0] == 'r' && input[1] == 'e' && input[2] =='a' && input[3] == 'd' && input[4] == ' ')
{	
    stuct NODE
    {
        string value;
        struct NODE * next;
    };
    string read(struct NODE *llist, //
}
Posted
Updated 3-Nov-11 7:56am
v2
Comments
Richard MacCutchan 4-Nov-11 5:25am    
Rather than switching between linked lists and arrays, you should spend some time thinking about what you are trying to achieve. What are the inputs required of your program? What are the outputs, and what are the data transformation requirements? Only when you understand these issues can you start to consider what structures would be best for holding the data internally.

1 solution

Take a look at some of these functions[^] and try to make life easier for yourself. You also need to switch to C++ if you wish to use the string class.
 
Share this answer
 
Comments
OriginalGriff 3-Nov-11 16:16pm    
The OP wrote:
"what if i dont make a link list and use an array? how would i go about doing that?"
Richard MacCutchan 4-Nov-11 5:25am    
Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900