68 760
Assignments Done
Successfully Done
In January 2019

Answer to Question #70675 in C++ for Esaan

Question #70675
consider a string of numbers, slashes, spaces, and miscellaneous character.
Say for example, "4!@/#@$6@#$ 7"
I want to extract numbers and slashes in the given format : a/b c
How do I extract only "4/6 7" from the above string in c++?
Expert's answer
#include <iostream>
#include <string>

using namespace std;

int main()
string s= "4!@/#@$6@#$ 7", result="";
//"4/6 7"
for(int i=0;i<s.size();i++)
if(s[i]>='0' && s[i]<='9'|| s[i]==' ' || s[i]=='/')
cout << "Result: " << result<<endl;

return 0;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


Assignment Expert
18.11.17, 19:14

You're welcome. We are glad to be helpful.
If you liked our service please press like-button beside answer field. Thank you!

17.11.17, 21:57

Thank you very much

Leave a comment

Ask Your question

Privacy policy Terms and Conditions