J
James Leddy
Hello
I'm writing a program that includes a call which returns a string, namely
getpass() in the standard c library. I was not surprised to learn that I
had improperly allocated memory to hold the return value. I don't really
know how a function returning a string works, and I have no knowledge at
compile time as to how long the string is going to be. Should I just
allocate enough memory for anything possible?
ex.
char *pass;
//pass = malloc(100) maybe 10000?
pass = getpwd("password: ");
Thanks,
I'm writing a program that includes a call which returns a string, namely
getpass() in the standard c library. I was not surprised to learn that I
had improperly allocated memory to hold the return value. I don't really
know how a function returning a string works, and I have no knowledge at
compile time as to how long the string is going to be. Should I just
allocate enough memory for anything possible?
ex.
char *pass;
//pass = malloc(100) maybe 10000?
pass = getpwd("password: ");
Thanks,