Hey guys, I am currently a student at University of North Texas and I am enrolled in CSCE 1020 which is the first course for computer science.
I have been doing pretty good and haven't needed much help but now I am reaching out to you guys in search of some help. I am not currently at my college right now as I have gone home for the weekend and I cannot figure something out.
What I am having problems with is writing my code. My objective in my lab is to find the last three letters of a "string".
So say the word is 'something'. I need to write a line of code that will return the last three letters. So "ing" would be returned to me.
What I have right now is this - im hoping im at least on the right track..
threelast = line.substr(line.length()-1);
cout << "Last three are: " << threelast << endl;
And here is my second last question of my Lab which is directly from my instructions.
Using a loop and the square-bracket [] notation to access each individual character in the string, display the string backwards (last character in the string first, next to last, etc). Remember that the character positions in a string are numbered starting with 0, so the first position in the string would be stringname[0], while the last position in the string would be stringname[stringname.length()-1]. Also remember that individual positions in a string can be referenced using integer variables, such as an integer counter for a loop that goes from stringname.length()-1 down to 0.
So when i input "SOMETHING" it needs to come back as "GNIHTEMOS"..
If you guys could please help me out I would be SOOOO thankful as this is due at midnight tonight. Thanks guys! and i look forward to contributing to the forum!
I have been doing pretty good and haven't needed much help but now I am reaching out to you guys in search of some help. I am not currently at my college right now as I have gone home for the weekend and I cannot figure something out.
What I am having problems with is writing my code. My objective in my lab is to find the last three letters of a "string".
So say the word is 'something'. I need to write a line of code that will return the last three letters. So "ing" would be returned to me.
What I have right now is this - im hoping im at least on the right track..
threelast = line.substr(line.length()-1);
cout << "Last three are: " << threelast << endl;
And here is my second last question of my Lab which is directly from my instructions.
Using a loop and the square-bracket [] notation to access each individual character in the string, display the string backwards (last character in the string first, next to last, etc). Remember that the character positions in a string are numbered starting with 0, so the first position in the string would be stringname[0], while the last position in the string would be stringname[stringname.length()-1]. Also remember that individual positions in a string can be referenced using integer variables, such as an integer counter for a loop that goes from stringname.length()-1 down to 0.
So when i input "SOMETHING" it needs to come back as "GNIHTEMOS"..
If you guys could please help me out I would be SOOOO thankful as this is due at midnight tonight. Thanks guys! and i look forward to contributing to the forum!