setup.c has the global variable login. How come this isn't variable visible in main.c? Here is the code and output that I get.
Code:$ more setup.c #include <pwd.h> #include <string.h> /*#include "me.h"*/ #define MAXLOGIN 64 char login[MAXLOGIN]; void init(void) { struct passwd *pwd; if ((pwd = getpwuid(geteuid())) == NULL) strcpy(login, "unknown"); else strcpy(login, pwd->pw_name); }
Code:$ more main.c /*I gave up trying to read Dr. Thalers code*/ #include <stdio.h> #include <stdlib.h> /*#include "me.h"*/ int main(int argc, char *argv[]) { /*begin the clownsuit and bra masturbation session*/ init(); printf("%s\n", login); exit(EXIT_SUCCESS); }
$ gcc -g setup.c main.c -o yapp
main.c: In function ‘main’:
main.c:13: error: ‘login’ undeclared (first use in this function)
main.c:13: error: (Each undeclared identifier is reported only once
main.c:13: error: for each function it appears in.)



LinkBack URL
About LinkBacks



