Help Me With The Solution To This Problem In C++ - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Help Me With The Solution To This Problem In C++ (1014 Views)
| Help Me With The Solution To This Problem In C++ by clockwisereport(op): 8:02am On Sep 03, 2019 |
Can you please help me rewrite this code using while loop and traditional for loop #include <iostream> #include <string> Using namespace std; void changeToX ( ) { string s; //prompt the user to enter the string cout<<"Enter the string you would like to change to X"<<endl; getline (cin, s); for (char &c : s) c = 'X'; cout <<s <<endl; } int main ( ) { changeToX ( ); } @lordZouga, @whizTim @kudaisi @segbolon |
| Re: Help Me With The Solution To This Problem In C++ by clockwisereport(op): 8:03am On Sep 03, 2019 |
Again, help me with the solution to this problem Write a program that reads a string of characters including punctuation and writes what was read but with the punctuation removed. Thank you |
| Re: Help Me With The Solution To This Problem In C++ by codekobo: 8:11am On Sep 03, 2019 |
// CPP program to remove punctuation from a given string #include <iostream> using namespace std; int main() { // input string std::string str = "Welcome @@##$ to#$% Code%$^Kobo$%^&.COM"; for (int i = 0, len = str.size(); i < len; i++) { // check whether parsing character is punctuation or not if (ispunct(str[i])) { str.erase(i--, 1); len = str.size(); } } // print string without punctuation std::cout << str; return 0; } Be sure to join the new platform for developers https://codekobo.com and consider using the discussion forums https://codekobo.com next time which has better features for developers like syntax highlighting |
| Re: Help Me With The Solution To This Problem In C++ by clockwisereport(op): 9:09am On Sep 03, 2019 |
Thanks @codekobo. Chukwu gozie gi |
| Re: Help Me With The Solution To This Problem In C++ by fr3do(m): 7:59am On Sep 04, 2019 |
I think not sure, if a method is going to ask for input, as in 'Cin', then the method name should reflect that input as in ' changeToX(String S)'. |
Simple Steps To Create Full Fledge MAUI Apps In C# • An INEC Voting Console Program Written In C Language • Please Help Me Solve This Problem In C++ • 2 • 3 • 4
WEBINAR: How To Get Started On Upwork And Tips To Land Your First Job • Short Killer|Fonekong Shortkiller Pro Mobile Phone Short Circuit Repair • Content Gorilla Ai Review - Will Content Gorilla Ai Write Quality Blog Post
@@##$ to#$% Code%$^Kobo$%^&.COM";