I am a small issue here...
I have my file as
//Mock Data
parse_line("456 222 0.981");
parse_line("789 999 0.982");
parse_line("123 111 0.983");
parse_line("456 333 0.984");
and I am reading it into a adjacency List.
the tings I am able to parse the first and the second column but not the third one.
it gives me result as
123 -> 111
456 -> 222 333
789 -> 999
when i want something like
123 -> 111 0.984
456 -> 222 0.981 333 0.984
789 -> 999 0.982
the functions i wrote are::
Code:
// Process the first column (Add it to main list)
struct mainList* process_first_col( int value )
{
#if MY_DEBUG
printf(" hey first value: %i\n", value);
#endif
// Search and add to the main list
return SortedInsertInMainList(value);
}
// Process the second column
// Add these to adjacency list of the current *node* pointer
void process_second_col( struct mainList* node, int value )
{
struct adjList *cur, *prev;
struct adjList **ptr = &node->pAdjListHead;
if((*ptr) == NULL)
{
(*ptr) = (struct adjList *)malloc(sizeof(struct adjList));
(*ptr)->nodeNum = value;
(*ptr)->pNext = NULL;
return;
}
cur = *ptr;
while(cur != NULL)
{
prev = cur;
cur = cur->pNext;
}
prev->pNext = (struct adjList *)malloc(sizeof(struct adjList));
prev->pNext->nodeNum = value;
prev->pNext->pNext = NULL;
#if MY_DEBUG
printf("second value: %i\n", value);
#endif
}
void process_third_col( struct adjList *node, float value1 )
{
struct adjList *cur, *prev;
struct adjList **ptr = &node;
if((*ptr) == NULL)
{
(*ptr) = (struct adjList *)malloc(sizeof(struct adjList));
(*ptr)->prob = value1;
(*ptr)->pNext = NULL;
return;
}
cur = *ptr;
while(cur != NULL)
{
prev = cur;
cur = cur->pNext;
}
prev->pNext = (struct adjList *)malloc(sizeof(struct adjList));
prev->pNext->prob = value1;
prev->pNext->pNext = NULL;
#if MY_DEBUG
printf("third value: %f\n", value1);
#endif
}
what am i doing wrong here?
thanks