25 lines
416 B
C
25 lines
416 B
C
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
|
|
|
|
void replace(char string[], char target, char replacement);
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
char test[] = "test";
|
|
printf("%s\n", test);
|
|
replace(test, 'e', 'a');
|
|
printf("%s\n", test);
|
|
return 0;
|
|
}
|
|
|
|
void replace(char string[], char target, char replacement){
|
|
int i = 0;
|
|
while(string[i] != '\0'){
|
|
if(string[i] == target){
|
|
string[i] = replacement;
|
|
}
|
|
i++;
|
|
}
|
|
}
|