Hi Zacs7, yes it is already a pointer to a linked list...
what I'm saying is from main() the code using 'g' will print out the entire set of lists iterating down the array of pointers...
but...
Type: Posts; User: occams razor
Hi Zacs7, yes it is already a pointer to a linked list...
what I'm saying is from main() the code using 'g' will print out the entire set of lists iterating down the array of pointers...
but...
I'm programming (in Ansi C) an adjacency list of an array with each element pointing to a list of structs and compiling with
gcc -Wall -ansi -pedantic -O *.c
my question is simply that from...
I've tried starting from the far end but have just made myself confused... tonight I'll have to go and nut out the algorithm a bit better I think. Its dinner time here now and probably part of it is...
Hi Salem, thanks for replying. A constraint on the learning exprience of this exercise is for me to use the structs as defined so I never chose the [1000]. I'm just finding it hard to come to terms...
At this point I am inserting the new student in the right place but the loop overwrites every member for the rest of the student struct... any ideas on how I might efficiently shuffle these along to...
Thanks for the reply...
The student struct doesnt have a next so only the nodes (units) are a linked list. [ADDED: -- The nodes are sorted by name in ascending order, these are courses BUT each...
this one has had me stuck for a few days and I am wondering if it is my idea of what is happening here that is askew...
typedef struct node *node_ptr;
struct node {
char *name;
...
no i have found the issue is in main... I'll work on it tomorrow and try to see what happened. I have a bit of junk code that compiled - thanks for looking at it though, greatly appreciated. :)
no, I realised n had no string being passed in... but unfortunately its still returning the exact same pointer no matter what - it returns NULL if its not in there but otherwise it returns the same...
sorry salem that ; shouldn't be there... :)
without the ; ...
I've noticed another issue with a previously working method not working at all so the problem may be elsewhere... does the find...
I have a problem working this one out for strings... this small function should return a pointer to fred for example if fred were in the list or NULL otherwise, a simple find operation. The output...
thanks Salem, I'll read the FAQ and scratch my head and wonder why I never even thought of that one... I am pretty new at C though for sure. :)
so basically at this point I can't really see why I'm getting those two cast errors on the second malloc and the strcpy functions...
any suggestions?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "list.h"
oh sorry... yes I have it in the top of the file with the function as the first malloc doesnt' throw an error...
#include <stdlib.h>
Hi, yes I think the header is alright but just to check...
#include "list.h" /* is on the same page as the function */
list.h contains:
typedef struct node *node_ptr;
struct node
I've got a function which should malloc for a new node and then for space for a string in the data_item part of the node... but for the life of me I can't figure out why I get two errors... here is...