Sorry thought I gave enough there. Alright I will explain more what I am trying to do and what I have done.
Alright, first my goal was to take some numbers from an infile or inputfile (any numbers). They happend to be 8,0,4,9...in the input file. Then I scanf the infile for numbers below with a fscanf and then they are passed up to some helper function which I will explain If I need to. Below is the scanning part.
Code:
/* insertion sort */
BasePtr start, p, add;
int x;
int length;
tmp = GetNode(0); ----->This line I believe might be my downfall, I believe it only works if the first number is the smallest.
start=tmp;
for (i = 0; i < 10; ++i)
{
if(fscanf(infile," %d", &x) !=1)
{
break;
}
printf("Adding node with data value %d\n", x); /* for debugging purpose */
add = GetNode(x);
p = FindInsLoc( start, add );
start = InsertNodeAfter( start, p, add );
}
printf("\n Total number of nodes added = %d\n", i);
printf("Sorted list ----- \n");
PrintList( start );
return 0;
}
---------My output below-----------
nuke@nuke:~$ ./a.out infile outfile
Adding node with data value 8
Adding node with data value 4
Adding node with data value 0
Adding node with data value 9
Total number of nodes added = 4
Sorted list -----
Val: 0
Val: 0
Val: 4
Val: 8
Val: 9
nuke@nuke:~$
So I am not sure how I would get rid of that zero...the first one because there is a zero in my infile.