C 中的警告称为“'s1' 和 's2' 在此函数中未初始化使用”

WARNING in c called " 's1' and 's2' is used uninitialized in this function"

无法解决 c 中的警告 called s1 s2 is used uninitialized this function

int main()
{
    char *s1, *s2;
    printf("Please enter string s1 and then s2:\n");
    scanf("%s %s", s1, s2);
    printf("%s %s", *s1, *s2);
return 0;
}

您必须为 s1s2 分配:

// do not forget to include the library <stdlib.h> for malloc function
s1 = malloc(20); // string length of s1 ups to 19;
if(!s1) {return -1;}
s2 = malloc(20) // // string length of s2 ups to 19 also;
if(!s2) {return -1;}

scanf中的函数,应该改为(Disadvantages of scanf):

scanf("%19s %19s", s1, s2); // or using fgets

或者你可以用字符数组代替指针:

char s1[20], s2[20];
// Or you can define a maximum length MAX_LEN, then using:
// char s1[MAX_LEN], s2[MAX_LEN];