+ 1

Please help me with this!!!

#include <iostream> #include <string> #include <stdio> // this library doesn't work here using namespace std; int main() { char str[20],ans,a,b; cout<<"Enter a String: "; gets(str); // even tried cin.getline(str,20); cout<<"\nDo need to replace a word: "; cin>>ans; if(ans=='Y'||ans=='y') { cout<<"Enter the word to be replaced: "; cin>>a; cout<<"\nWith word: " cin>>b; int s =strlen(str); for(int i=0;i<s;i++) { if(str[i]==a) { str[i]=b; } } puts(str); } return 0; }

26th May 2020, 5:11 PM
SKALVANOV
SKALVANOV - avatar
4 Réponses
+ 1
What is the problem?
26th May 2020, 5:13 PM
Emanuel Maliaño
Emanuel Maliaño - avatar
+ 1
Thank but I already looked for the problem in my book so the issue is with compiler because sololearn codebock instead of turbo !!! The solution is cstdio
28th May 2020, 9:55 AM
SKALVANOV
SKALVANOV - avatar
0
Stdio is the problem... check out the comments!!!!
27th May 2020, 9:00 AM
SKALVANOV
SKALVANOV - avatar
0
Try this but it doesn't work #include <iostream> #include <string.h> #include "stdio.h" int main(){ char str[20],ans,a,b; std::cout<<"Enter a String: "; gets(str); Doing a little research I found that gets() was deprecated in C++11 and removed from C++14.
28th May 2020, 1:25 AM
Emanuel Maliaño
Emanuel Maliaño - avatar