关于#c语言#的问题:正确应该输入输出相同(输入:hello输出:hello)但现在是不相同的(输入:hello输出:ello)#include <stdio.h>

申请对应空间大小,读取字符串,最终输出字符串。
但是输出的结果不对。
正确应该 输入输出相同(输入:hello 输出:hello)
但现在是不相同的(输入:hello 输出:ello)

#include<stdio.h>
#include<stdlib.h>
int main()
{
int i;
scanf("%d",&i);
char c;
scanf("%c",&c);
char *p;
p=(char*)malloc(n);
fgets(p,i,stdin);
puts(p);
return 0;
}

应该用 i 替换 n ,不然怎么能运行。

你都是怎么输入的呢?截图看看
第10行突然冒出一个n,惊出一身冷汗