I explained absolutely everything in my code comments and suggest you read them.
Quote:
while(l->next != NULL)
I feel like I'm missing something. Like cause I can't see the reason for looping
through l->next.
If you delete the current node, the previous node is left pointing to invalid memory.
when you call free() on memory block 2, what happens to memory block 1? Absolutely nothing. It still points to memory block 2. It doesn't know it's the last node in the list! Next time you use the list it'll try to access block 2 anyway, and either crash or do strange things.
Whenever you're not at the first node in the list, you need to check and free the next node, not the current one, otherwise you'll leave dangling pointers all over the place.
Quote:
I'm just wondering if you did that second part just in case I want l to be iterated
through but I gotta make sure.
I explained exactly why I did absolutely everything in the comments I put in my code, I suggest you read them. If you don't understand my comments, ask questions about them, please don't just ignore them.
Quote:
My problem is the fact that I want descr_list to have struct descr *p as
a part of itself and I thought initializing a null part of d would do that but
now I am thinking that it wont.
If I get your meaning, it won't.
A pointer is a memory address and nothing more. Trying to initialize a NULL means trying to write to address 0 in memory, which crashes.
Since you never actually posted your data structures, I certainly can't show you how to fix them.
Quote:
Ok so heres a huntch I have at making the structure descr *d part of
descr_list. Maybe I just change the value adescr_list untill it is pointing to
a NULL structure and then make it equal to d.
Changing the pointers doesn't change the memory. Please read the examples I posted for you about array indexes.
How about:
Quote:
What do I have to add to this function to make a list of player structures out of the global variable descr_list?
something like while descr_list->next != NULL descr_list= descr_list->next descr_list ->next = p.
There's only two times you'd change the value of descr_list.
1) When the list is empty. descr_list must be set to the new first node.
2) When the first node is being deleted. descr_list must be set to the next node.
If you need to add a 'self' pointer to keep your code together, you must be doing something very strange indeed.
---------- Post updated at 06:56 AM ---------- Previous update was at 06:20 AM ----------
So what do you think?
Will she work?
I think I have finally done it.[/quote] For yog's sake. If you've posted 5 times while I'm asleep, posting a 6th won't make me wake up.
I can't tell if your code works or not since you changed the structures again and didn't post what it now is, but it looks like you've added 3 or 4 useless pointers which are only helpful for working around bugs in your code.
[/QUOTE] It will not work, for all the reasons I gave you in my last post, which I really, really, really wish you'd read.
---------- Post updated at 11:43 AM ---------- Previous update was at 11:09 AM ----------
And you're still forgetting all your return 1's! The return 0's and error checking are useless if you don't return success when you actually have success!
Here's working code for a linked list.
Last edited by Corona688; 09-30-2011 at 02:56 PM..
:cool: I like Vibhory2 like the idea of tapping into the kernel.. although not as indepth as he/she... i want to create a virtual databse of a few ma chines with connectivity and defiinte knowledge to create it.. I havebeen working on the project for a year now.. ! before unix (1 year exactly) i... (20 Replies)
I installed Oracle 10 software on Solaris 11 Express, everything was fine execpt I can't create database using dbca.rsp file. I populated file with following options.
OPERATION_TYPE = "createDatabase"
GDBNAME = "solaris_user.domain.com"
SID = "solaris_user"
TEMPLATENAME = "General... (0 Replies)
Hi,
I have backup file of database in my server. I want to create a that database in the same Mysql Server. How can I do that?
Please send the steps to create the database using backup file?
Thanks a lot, (1 Reply)
Hi.
I have two text files(tables) which include some information and I want to make some query codes using them.
First of all, I want to create bash script that read this two tables, create/open database and insert data from files into database.
#!/bin/bash
while read line; do
... (1 Reply)
Hello ,
I am new in this forum and need your help as I am totally confused :confused:
I read a lot of threads and tried to search a lot but did not get the exact answer to my question.
I just want a simple (content wise may be long) shell script to create oracle database.
In detail:... (5 Replies)
#!/bin/bash
user=`mysql userList -uuserlist -puserlistpassword -s -N -e "SELECT userName FROM users WHERE activated='n'"`
for i in $user; do
useradd "$i" -m
doneThis is what I have done so far. But obviously it still does not work.
I'm trying to create users based on information stored in a... (5 Replies)
Hi all,
I new to scripting and i need to know how to put the script when the capture goes down in the feeds database.. I tried with this "ps -ef | grep asn" command and it displaying the capture,apply time. But the alert we are receving now is replication is failed . So i need to develop the... (1 Reply)
Hello,
Please suggest me the ways how to get graphical interface on AIX server.I need to create oracle database for which I need graphical access.
Best regards,
Vishal (4 Replies)
Hi Guys,
I have a list a hotels stored in many different text files.
This list is kept in the following format:
20/03
Hotel:
The Bear Hotel
Honey Street
Woodstock
UK
Tel:+44-xxxxxx
Rate: 100
21/03
Hotel:
The Bush Hotel
Nice Street
Farnham (4 Replies)