user-0 提问: 设好的程序出错warning C4047:  求大神指导

回复:
user: user-1
content: #include <stdio.h> #include <string.h> int main() {     char n_name[256] = {0};     printf("请输入你的名字:");fflush(stdout);     scanf("%s",&n_name);     if(strcmp(n_name, "幺妹") == 0)     {         printf("ILOVEYOUILOVEYOUILOVEYOUILOVEYOUILOVEYOUILO\n"                "ILOVEYOUILO ****** VEYOU ****** ILOVEYOUILO\n"                "ILOVEYOU *********** I *********** LOVEYOUI\n"                "OUIUI *************** *************** VEYOU\n"                "YOUI ********************************** LOV\n"                "IL ************************************* OV\n"                "L *************I**LOVE**YOU*!************ O\n"                "I *************************************** L\n"                "U *************************************** I\n"                "OU ************************************* IL\n"                "UIL *********************************** OVE\n"                "OVEYO ******************************* ULOVE\n"                "OVEYOUI **************************** LOVEYO\n"                "EYOUILOVE *********************** YOUILOVEY\n"                "VEYOUILOVEYOU ***************** ILOVEYOUILO\n"                "ILOVEYOUILOVEYO ************* LOVEYOUILOVEY\n"                "UILOVEYOUILOVEYOU ********* LOVEYOUILOVEYOU\n"                "LOVEYOUILOVEYOUILOV ***** ILOVEYOUILOVEYOUI\n"                "EYOUILOVEYOUILOVEYOU *** YOULOVEYOUILOVEYOU\n"                "VEYOUILOVEYOUILOVEYOU * VEYOUILOVEYOUILOVEY\n"                "OVEYOUILOVEYOUILOVEYOUILOVEYOUILOVEYOUILOVE\n");     }     else         printf("对不起，这个程序不是给你的噢！！");     getchar();     return 0; }

user: user-2
content: 小伙子，好样滴。好好爱她。 #include <stdio.h> #include <string.h> void main() { 	char n_name[256] = {0}; 	printf("请输入你的名字:"); 	scanf("%s",&n_name); 	if(strcmp(n_name, "张三") == 0) 	{ 		printf("·····································\n"); 		printf("          **            **\n"); 		printf("         ****          ****\n"); 		printf("        ******        ******\n"); 		printf("       ********      ********\n"); 		printf("      **********    **********\n"); 		printf("     **************************\n"); 		printf("    ****************************\n"); 		printf("     ***************************\n"); 		printf("      *************************\n"); 		printf("       ***********************\n"); 		printf("        *********************\n"); 		printf("         *******************\n"); 		printf("          *****************\n"); 		printf("           ***************\n"); 		printf("            *************\n"); 		printf("             ***********\n"); 		printf("              *********\n"); 		printf("               *******\n"); 		printf("                *****\n"); 		printf("                 ***\n"); 		printf("                  *\n"); 		printf("·····································\n "); 	} 	else 		printf("对不起，这个程序不是给你的噢！！"); 	getchar(); }

user: user-3
content: 可以用的  只不过你需要的是名字 应该是字符串类型的数据   而你却定义的int型数据 改为楼上所说的： char n_name[10]; printf("请输入你的名字"); scanf("%s",n_name); if(strcmp(n_name,"······") == 0) {    // do something }

user: user-0
content: 引用 1 楼 u014723382 的回复:没这个库sting.h.strcmp这个函数是对字符进行操作的，需要string.h 这个库。你改改试试加上string.h之后还会出现那个错误

user: user-0
content: 引用 1 楼 u014723382 的回复:没这个库sting.h.strcmp这个函数是对字符进行操作的，需要string.h 这个库。你改改试试加了之后就出现这个错误fatal error C1083: Cannot open include file: 'sting.h': No such file or directory

user: user-3
content: 同楼上 另外strcmp是用来比较字符串是否相等的 if(strcmp(n_name,"······") == 0)

user: user-4
content: int n_name;    printf("请输入你的名字");     scanf("%d",&n_name); 改为： char n_name[10];    printf("请输入你的名字");     scanf("%s",n_name);

user: user-5
content: scanf("%d",&n_name);  改成scanf("%s",&n_name);

user: user-0
content: 引用 6 楼 xydp1987108 的回复:同楼上 另外strcmp是用来比较字符串是否相等的 if(strcmp(n_name,"······") == 0)那strcmp是不能用吗？那应该用什么？？

user: user-6
content: 没这个库sting.h.strcmp这个函数是对字符进行操作的，需要string.h 这个库。你改改试试