+ 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; }
4 Answers
+ 1
What is the problem?
+ 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
0
Stdio is the problem... check out the comments!!!!
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.