I have to read some text from console and then search for the text “simple” in that string. I have:
char Buffer[200];
cin >> Buffer; //read text form keybord
char str[] = Buffer;
char * pch;
pch = strstr (str,"simple");
strncpy (pch,"sample",6);
puts (str);
How to convert Buffer[200] to str[] so that the program works.
If you insist on using C-style strings, you’d probably want something like:
If you want to write actual C++, you’d probably do something more like: