I'm getting random characters after the actual output in printf("%s",result);
.
Why are these characters being printed? And how can I remove them?
#include<stdio.h>
char *replacechar(char[]);
int main()
{
char str[25];
char *result;
int i=0;
while( (str[i++]=getchar()) != '\n' && i < 25);
result= replacechar(str);
printf("%s",result);
return 0;
}
char *replacechar(char str[])
{
return str;
}
Expected Output:
aaayt
aaayt
Actual Output:
aaayt
aaayt
↑@