mercredi 18 août 2021

why 'if 'construct is not running in this C code? [duplicate]

i have entered 'pass1' as a value to 'str' so that 'if' construct would work but still its not working. code is down below:

code:

#include <stdio.h>
#include <string.h>
#define ab "pass1"

int main() {
  char pass[8];
  char str[8];
  printf("Enter a string :");
  gets(str);
  strcpy(pass, str);

  printf("your string is %s ", str);

  if (pass == ab) {
    printf("la swagat cha!");
  }
}

Aucun commentaire:

Enregistrer un commentaire