I cannot for the life of me figure out how to get stuff out of my array that i pass to my function(listSort()). all i want for example is data[0] in my function that i called. i can figure out the rest of what i'm supposed to do if i can do this. any help is greatly appreciated! (this is for a linkedList sort program, so i cant do a simpler array type)
main.c
Code:
[tag]
#include <stdio.h>
#include <time.h>
#include "list.h"
#define ARRAY_SIZE 4
int main() {
double data[] = {9,3,4,2};
int i;
listSort(&data);
for (i = 0; i < ARRAY_SIZE; i++)
printf("%g\n", data[i]);
}
[/tag]
listSort.c
Code:
[tag]
#include <stdio.h>
#include <assert.h>
#include "list.h"
void listSort (struct linkedList * lst){
double u;
u = lst[0]; //<----------------------------here is what i cant figure out. how do i access the data in lst???
printf("%g\n", n);
[/tag]
i dont know if my .h file matters.... but i'll include it anyways i guess. (i have all these already coded)
list.h
Code:
list.h[tag]
#ifndef _list_
#define _list_
#ifndef Eletype
#define EleType double
#endif
struct dlink{
EleType value;
struct dlink * next;
struct dlink * prev;
};
struct linkedList{
int size;
struct dlink * frontSentinel;
struct dlink * backSentinel;
};
void listSort (struct linkedList * lst);
void LinkedListInit (struct linkedList *q);
void linkedListFree (struct linkedList *q);
void linkedListAddFront (struct linkedList *q, EleType e);
void linkedListAddBack (struct linkedList *q, EleType e);
void linkedListRemoveFront (struct linkedList *q);
void linkedListRemoveBack (struct linkedList *q);
int linkedListIsEmpty(struct linkedList *q);
void _addLink(struct linkedList *q, struct dlink *lnk, EleType e);
void _removeLink(struct linkedList *q, struct dlink *lnk);
EleType linkedListFront (struct linkedList *q);
EleType linkedListBack (struct linkedList *q);
#endif
[/tag]
i've looked at over a dozen tutorials and example code, everything is posted in a single .c file(or .cpp), i need to put these in 2 different ones. thanks for your time!