gpt4 book ai didi

如果语句不起作用,控制台会发出警告

转载 作者:行者123 更新时间:2023-11-30 21:02:39 24 4
gpt4 key购买 nike

#include <stdio.h>
#include <stdlib.h>
#include<string.h>

int main()
{
char buffer[1024];
printf("Hello\n");
printf("What would you like to search\n");
printf("Here are the options\n");
printf("s : How are you\n");
printf("c : What would you like to search\n");

scanf("%s",&buffer);

if(buffer == 's')
printf("iam fine\n");
else if (buffer == 'c')
printf("What would you like to search\n");

fgets(buffer, sizeof buffer, stdin);
system(buffer);
return 0;
}

控制台错误(程序无法正常运行)

C:\Users\sc\Documents\ForumCode\test\foo.c|12|warning: format '%s' expects type 'char *', but argument 2 has type 'char (*)[1024]'|
C:\Users\sc\Documents\ForumCode\test\foo.c|13|warning: comparison between pointer and integer|
C:\Users\sc\Documents\ForumCode\test\foo.c|15|warning: comparison between pointer and integer|

||=== Build finished: 0 errors, 3 warnings ===|

最佳答案

应该是 scanf("%s",buffer)

关于如果语句不起作用,控制台会发出警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28946599/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com