I'm new to coding and I've been studying C recently. Basically, I wanted to create the following function, which modifies every string element:
char *stralt(char *s, char ch)
{
int i;
for (i=0; i!='\0'; i++)
s[i] = ch;
return s;
}
And when I try to use it on int main(), like this:
int main()
{
printf("%s", stralt("test",'x'));
}
The prompt shows "test" instead of "xxxx". What is wrong with this code and how could it work properly? Thanks!