Pointer s
doesn't get any value. I can't figure out why.
Variable v
in exposeStatic()
always get desired values.
Please advise.
main.c
#include <stdio.h>
#include <stdlib.h>
#include "myLib.h"
struct node *s = NULL;
int main()
{
populateStatic();
exposeStatic(s);
printf("myLib myStatic adress: %p\n", s);
return(0);
}
myLib.h
#ifndef myLib
#define myLib
struct node
{
int data;
struct node *next;
};
void exposeStatic(struct node *v);
void populateStatic();
#endif
myLib.c
#include <stdio.h>
#include <stdlib.h>
#include "myLib.h"
static struct node *myStatic = NULL;
void exposeStatic(struct node *v)
{
v = myStatic;
}
void populateStatic()
{
struct node *p = (struct node *)malloc(sizeof(struct node));
p->data = 855; // assume there is some data from populateStatic() arguments
p->next = NULL; // assume there is some data from populateStatic() arguments
myStatic = p;
}