I didn't paste the header file which is where I place those library, but I still have question:
Code:
#include "vncstudent.h"
#include <unistd.h>
#include <string.h>
int main()
{
padd();
printf("1:%s\n", HDIR);
pprint();
return 0;
}
void padd()
{char cwd[256];
char HDIR[256];
if(getcwd(cwd, sizeof(cwd))==NULL)
{
}else
{
strcat(HDIR, cwd);
printf("cwd = %s\n", cwd);
}
printf("a:%s\n", HDIR);
}
Code:
#include "vncstudent.h"
#include <string.h>
void pprint()
{
char HDIR[256];
printf("in pp:%s\n", HDIR);
printf("ok\n");
}
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
extern char HDIR;
void pprint();
void padd();
int main();
Code:
vncstudent: vncstudent.o pprint.o
gcc -o vncstudent vncstudent.o pprint.o
pprint.o: pprint.c vncstudent.h
gcc -o -c pprint.c
vncstudent.o: vncstudent.c pprint.c vncstudent.h
gcc -o -c vncstudent.c
clean:
rm -f vncstudent vncstudent.o pprint.o
I have changed some mistakes and fixed everything I can. I have it run in the mac os x.
In fact, I just want to be able to read the current working dir and have very function be able to call the variable, HDIR.
pprint is already included in the header file, it doesn't make sense to complain?
HDIR is also setup ok?
but I still get the following weird message:
$ make vncstudent
cc vncstudent.c -o vncstudent
vncstudent.c: In function ‘main’:
vncstudent.c:10: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘int’
Undefined symbols:
"_pprint", referenced from:
_main in ccCMSzuA.o
"_HDIR", referenced from:
_main in ccCMSzuA.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [vncstudent] Error 1