scanf v.s. assign string directively
123456789101112131415161718192021222324252627282930313233343536
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char *s = "Hi!";
char *t = "Hi!";
char *x = malloc(5);
char *y = malloc(5);
printf("x: ");
scanf("%s", x);
printf("y: ");
scanf("%s", y);
if (s == t)
{
puts("s, t: Same");
}
else
{
puts("s, t: Different");
}
if (x == y)
{
puts("x, y: Same");
}
else
{
puts("x, y: Different");
}
}
C
INFO