string replace_strings (FILE *in, FILE *out, char *what, char *repl)
{
int x = strlen(what);
int z = strlen(repl);
string newWhat(what, x);
string newRepl(repl, z);
char c;
char *str; //наш буффер
int i = 0;
size_t found;
这样做是个糟糕的决定,我知道
while(!feof(in))
{
while((c!='\0') && (i<=255))
{
str[i] = fscanf(in, "%c", c);
i++;
}
string newStr (str, i);
while(found != string::npos)
{
found = newStr.find(newWhat);
newStr.replace(found, newWhat.length(), newRepl);
}
fprintf(out, "%s", newStr.c_str());
它返回分段错误,怎么了?我应该怎么办?帮帮我伙计们