This is part of a lab assignment
I have to implement the following function...
void replaceChar(char s[], char c,int len)
Description: Replace every character of
s
withc
.len
indicates the length ofs
.
I submit this to the autograder that my class uses and it tells me that "the length of the replaced string has different length." I have tested this extensively and do not see any issues. Here is my complete function:
void replaceChar(char s[], char c, int len) {
printf("\n");
for (int i = 0; i < len; i++) {
s[i] = c;
printf("%c",s[i]);
}
}
I appreciate any help you can give me!
Here are a few of my test cases:
char s1[5] = {'h','e','l','l','o'};
char s3[10] = {'h','e','l','l','o',' ','h','i','i','i'};
char rep1 = 'x';
replaceChar(s1,rep1,5);
replaceChar(s3,rep1,10);