All pastes #52884 Raw Edit

Untitled

public cpp v1 · immutable
#52884 ·published 2006-05-02 14:53 UTC
rendered paste body
/*Write a program to read strings from the standard input, concatenating what is read into one large string. Print the concatenated string. Next, change the program to separate adjacent input strings by a space.*/#include "stdafx.h"#include <iostream>#include <string>using namespace std;int main() {	string new_str, my_str = "";	bool proceed = true;	while(proceed){		cout << "Please enter the string:" << endl;		// read line		getline(cin, new_str);		my_str += new_str + "\12";				cout << "New string? Y/N  :";		getline(cin, new_str);		if(new_str == "N"){proceed = false;}	}		cout << "Whole entered string is:" << endl;	cout << my_str << endl;	// second part	cout << "Separating by spaces:" << endl;	cout << "Size: " << my_str.size() << endl;	for(string::size_type ix=0; ix !=my_str.size(); ++ix){		if (my_str[ix] == ' '){			my_str[ix] = '\12';		}	}	cout << "The result is: " << endl;	cout << my_str << endl;	return 0;}