#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char str[80];
char find[10];
char change[10];
char* pstr;
char* temp = new char[80];
cin.getline(str, 80);
cin.getline(find,10);
cin.getline(change,10);
pstr =strstr(str,find);
int a = str.find(pstr);
int len;
len = strlen(find);
str.replace(a,len,change);
delete []temp;
cout<< str<< endl;
return 0;
}
The error message is:
Main.cpp: In function ‘int main()’: Main.cpp:18:15: error: request for member ‘find’ in ‘str’, which is of non-class type ‘char [80]’ int a = str.find(pstr); ^ Main.cpp:21:7: error: request for member ‘replace’ in ‘str’, which is of non-class type ‘char [80]’ str.replace(a,len,change); ^
For example,
what is your nam / nam / name
the output is
'what is your name'
what is matter?