每當我運行下面的代碼,並給輸入長串它就會有返回值3221226356過程中獲得退出,返回值3221226356
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
int i=0;
char c,*input;
input=(char *)malloc(sizeof(char));
if(input==NULL)
{
printf("Could not allocate memory");
exit(1);
}
printf("%d size",strlen(input));
printf("Enter the string: ");
while((c=getchar())!='\n')
{
realloc(input, (sizeof(char)));
input[i++]=c;
}
printf("%s",input);
}
realloc(input,(sizeof(char)));返回值 – 2014-09-23 06:09:31