当我输入我想要查找的字符位置时,此代码停止工作,另外,我需要使用 str 作为指针和 malloc 来重新制作它
int main(void)
{
char str[10];
int pos;
puts("Type a text");
gets(str);
puts("Type a position");
scanf("%d", pos);
pos = pos - 1;
printf("%s", str[pos]);
system("pause");
return 0;
}
最佳答案
也许你想做:
scanf("%d", &pos);
关于c - C 中带有字符串的 Malloc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25495465/