i'm making a little program in c++ and i've ran on a small problem.
I want to make a global char array called password which would store the password entered by the user for the whole time the program is using.
What i've tried is doing it like that:
main.h:
extern char* szUserPassword;
main.cpp:
char* szUserPassword;
The other file where I am trying to allocate the memory:
szUserPassword = (char*) malloc(sizeof(char) * strlen(inputtext));
And the error is:
Quote
error LNK2001: unresolved external symbol "char * szUserPassword" ([email protected]@3PADA)
However, it works locally:
char* testallocation; testallocation = (char *) malloc(sizeof(char) * strlen(inputtext));
But the problem is that I need it globally not locally.
I have no ideas how to fix that, searched the internet but I dont even know how i would call this problem.
Thanks in advance

New Topic/Question
Reply


MultiQuote




|