Thursday, March 16, 2017

C++ Part 29

C++ Strings Part II

If you didn't read the first part, you can find it here.
getline: may input spaces, as before.
e.g., getline(cin,s1) would assign “Navid Plus” to s1 in the "Navid Plus" example.
Example :

#include <iostream>// Coded by https://NavidPlus.blogspot.com#include <string>
#include<cstdlib>
using namespace std;

int main ( )
{
    string backString;
    cout << "What ever your going to write here, I will reverse it. " <<endl;
    getline (cin,backString);
    int theIndex = backString.length()-1;
    while ( theIndex >= 0)
    {
       cout << backString [theIndex] ;
       theIndex --;
    }
    cout << '\n' ;
}

No comments:

Digital Design Part 3

4th→ assembler translates it to the machine language. 1.6 [20] <§1.6> Consider two diļ¬€erent implementations of the same instru...