![]() |
|
#1
|
||||
|
||||
controlling contents of a linked list ?greeting!
Just found a sample linked list program and I've decided to play around with it (hoping that I can incorporate it with the project I'm currently working on). here is the code: (this is only a quick hack/modification on the sample program that I've found, I haven't fix the warning message yet) CPP / C++ / C Code:
the question is, what would I have to do in order for the contents of a linked list to be place in one string (character array). to elaborate more. let say the content of the Read.text (which can vary )are as follows: Quote:
into this format Quote:
any kind of help or comment will be much appreciated. regards, jaro __________________
Action.....reAction |
|
#2
|
|||
|
|||
Re: controlling contents of a linked list ?Quote:
Quote:
I'm not sure what warning messages you are getting (you might tell us if you still have problems after what I am about to show you), but the following is the way that I usually handle typedefs for self-referential structs. There are other ways, but for me, this lets the thing compile with no messages: CPP / C++ / C Code:
Quote:
Well, you already have a loop that goes through and adds up the total number of chars in all of the lines, so you could just allocate some storage and use strcat() or some such thing to copy everything into that. Maybe something like this: CPP / C++ / C Code:
Now, since you used fgets() to read the lines into the buffer, they probably have '\n' characters at the end of each line, so if you want one long string without any newline chars you will have to get rid of them somehow. Actually, you probably want to replace '\n' chars with space chars (I would probably use strchr() to locate the newline chars and to tell me where to put the space chars). You could do that as you read the lines in or when you concatenate them. Your choice. Regards, Dave |
|
#3
|
||||
|
||||
Re: controlling contents of a linked list ?Quote:
Thanks Dave, adding these remove all the warning message. I'll try to implement your suggestions to my program, will post again for some update. -jaro __________________
Action.....reAction |
|
#4
|
||||
|
||||
Re: controlling contents of a linked list ?just finished working on the program.
Did some adjustment and add some extra function along the way. Just want to hear some comment about the code and if I violate some coding rules. here is the code: CPP / C++ / C Code:
The content of the Read.txt remains the same. output Quote:
Forgot to mention on my first post that I'm using MVC6 under Win2K. ~jaro __________________
Action.....reAction |
Recent GIDBlog
Developing GUIs with wxPython (Part 2) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Airport Log program using 3D linked List : problem reading from file | batrsau | C Programming Language | 11 | 29-Feb-2008 07:44 |
| [Include] Doubly-linked List | dsmith | C Programming Language | 6 | 14-Apr-2006 13:12 |
| linked list error message | Krandygrl00 | C++ Forum | 4 | 22-Jun-2005 14:13 |
| search linked list | itsmecathys | C++ Forum | 20 | 18-Apr-2005 01:34 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The