For example, I am writing a C function that replace a substring s1
in string source
with a new string s2
. But I am having trouble with reading the input from stdin. I also want it to end until an EOF
is met.
I search a lot about "read until EOF" and "read a string containing whitespace", but I didnt make it to work.
#include <stdio.h>
{
char source[120], s1[20], s2[20];
...
//what ever to input multiple cases of source, s1, and s2 until EOF is met
replace(source, s1, s2);
printf("%s\n",source);
return 0;
}