December 12th, 2013, 08:36 AM
String input and manipulation.
Hey guys. I've been stuck on an assignment, and it's an online course so the professor hasn't responded to my email for a couple of days. I'm supposed to make a program that does the following:
1. Reads in a line consisting of a studentís name, Social Security number, user ID, and password.
(This part is obvious, no issues here).
2. Output the string in which all the digits of the Social Security number, and all the characters in the password are replaced by x.
(This is where I'm having trouble)
I believe I'll need to use several string functions to achieve this, such as strVar.length() or strVar.size(), strVar.find_first_not_of (),
I'm wondering if it's possible to use strVar.find_first_not_of() to find the first of any integer (since the input goes Name, SSN, ID, password). Then use the swap function?
If anyone's at all familiar with string manipulation, I'd greatly appreciate some advice. Thanks
December 12th, 2013, 01:42 PM
What are the rules to find tokens in the input?
If you knew the index of the ends of the password I would think this code ought to help:
for (i=left;i<right;++i) the_string[i] = 'x';
The interval [left, right) is inclusive on left, exclusive at right.
[/code] are essential for python code and Makefiles!