Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,550 members, 7,955,050 topics. Date: Saturday, 21 September 2024 at 03:25 PM |
Nairaland Forum / Science/Technology / Programming / Help Me With The Solution To This Problem In C++ (948 Views)
An INEC Voting Console Program Written In C Language / Please Help Me Solve This Problem In C++ / Please,Help Explain This Code In C (2) (3) (4)
Help Me With The Solution To This Problem In C++ by clockwisereport: 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: 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 2 Likes |
Re: Help Me With The Solution To This Problem In C++ by clockwisereport: 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)'. |
(1) (Reply)
What Do You Think About This Guys? My Friends Latest Multi-purpose Site.. / Java And Oracle Which Is Best? / I Want To Be A Part Of The It Industry
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 9 |