If I have a pointer say int **pa that stores the address to another pointer int *pb, pa would be storing the address of pb which contains an address to lets say int c = 10. Picking an arbitrary address for pb to be 5009 and c to be 2331. Can someone verify for me if I have the following values correct:
pa = 5009
pb = 2331
*pb = 10
would **pa = 2331? If so, how can I obtain the value of c through pa?
I'm trying to write a function that deletes a record from a linked list by name:
struct record
{
char name[25];
char address[80];
int yearofbirth;
char telno[15];
struct record *next;
};
From what I read in my textbook and online from the net...the list will start with a struct record pointer that stores the address of the first record. So when I start my delete function, I would pass the address of that pointer into the function in order to alter the next field should the first record is the one that needed to be deleted. Therefore the param should be struct record **start. The value in start would be the address to the pointer that stores the address of the first record. Then the value in the address of the record pointer can be obtain through **start. How can I obtain the value whose address is stored in record pointer through start?
Oh well, not so quick question...lol.
EDIT: One way I thought of was to declare another struct record pointer and define it to be **start (value, address to first record) Then should it turns out that the first record contains the name to be deleted, the following code should modify the list:
struct record *nextRecord = ** start
nextRecord = nextRecord.next
clear record whose address is in **start from heap
**start = nextRecord
Is this the correct syntax? Is there another way to do this? Would it just be better to start the list with a struct record instead of a struct record pointer?
Thanks,
jthep
pa = 5009
pb = 2331
*pb = 10
would **pa = 2331? If so, how can I obtain the value of c through pa?
I'm trying to write a function that deletes a record from a linked list by name:
struct record
{
char name[25];
char address[80];
int yearofbirth;
char telno[15];
struct record *next;
};
From what I read in my textbook and online from the net...the list will start with a struct record pointer that stores the address of the first record. So when I start my delete function, I would pass the address of that pointer into the function in order to alter the next field should the first record is the one that needed to be deleted. Therefore the param should be struct record **start. The value in start would be the address to the pointer that stores the address of the first record. Then the value in the address of the record pointer can be obtain through **start. How can I obtain the value whose address is stored in record pointer through start?
Oh well, not so quick question...lol.
EDIT: One way I thought of was to declare another struct record pointer and define it to be **start (value, address to first record) Then should it turns out that the first record contains the name to be deleted, the following code should modify the list:
struct record *nextRecord = ** start
nextRecord = nextRecord.next
clear record whose address is in **start from heap
**start = nextRecord
Is this the correct syntax? Is there another way to do this? Would it just be better to start the list with a struct record instead of a struct record pointer?
Thanks,
jthep
Comment