gpt4 book ai didi

c - 为什么不打印字符串?

转载 作者:行者123 更新时间:2023-11-30 21:17:04 29 4
gpt4 key购买 nike

它只打印FG,其他字符都是垃圾

#include<stdio.h>

void putstr(char *s1[])
{
while(*s1!='\0')
{
printf("%c",*s1);s1++;
}
}

int main()
{
char s1[10]="fedfgh";
putstr(s1);
}

最佳答案

void putstr(char *s1[]) 这是错误的。 putstr 的实际参数是一个数组(它会衰减为指针),但形式参数表示 putstr 接受指向 char 的指针数组。

使用void putstr(char *s1)void putstr(char s1[])

关于c - 为什么不打印字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47810268/

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