0
#include <stdio.h>
#include <unistd.h>
int main()
{
  char *itm;
  char *qnt;
  qnt,itm = getpass("");
  printf("%s %s ",qnt,itm);
    return 0;
}

So if i run this code in online compiler like replit , it runs without error . But when i run it in codeblock , it throws an error stating undefined reference to 'getpass' . how to fix this ?

doctorlove
  • 18,872
  • 2
  • 46
  • 62
  • Which compiler are you using? – doctorlove Dec 07 '22 at 15:06
  • The manpage for `getpass` states you need to use `#include `. Have you tried that? – DaveyBoy Dec 07 '22 at 15:09
  • 2
    Much of the documentation for `getpass` states clearly "this function is obsolete, do not use it". Why are you using it? – William Pursell Dec 07 '22 at 15:11
  • The `getpass()` function is obsolete and has been withdrawn from POSIX. It should not be used. Among other issues, you may find -- as indeed you have done -- that some POSIX-compliant C implementations don't provide it at all. And, of course, C implementations that are *not* POSIX compliant could never be assumed to provide it. – John Bollinger Dec 07 '22 at 15:13
  • 1
    Also, I doubt qnt,itm = getpass("") does what you hope. A function can only return one thing. It's valid (but very, very odd) C, but qnt doesn't get assigned anything. – pmacfarlane Dec 07 '22 at 15:20

0 Answers0