help c++

03/11/2014 19:31 _Entropia_#1
hi guys.
my problem is this,How can I assign all letters printed of the console in "string savetext;".
[Only registered and activated users can see links. Click Here To Register...]
PHP Code:
#include <iostream>
#include <string>
#include "stdafx.h"
using namespace std;

int _tmain(int argc_TCHARargv[])
{
    
string age;
    
cout << "asdasdkjwhrjkweh jwehkj wjekwjkerwejhr\n asdasjdghasgdyueghj\jushduiasghdis";
    
getline(cinage);
    
cout << "748586412341114 4 4df4 4sf" << endl;

    
string savetext;

    
system("pause");
    return 
0;

I hope your answers, tranks ^^.

PS: sorry for my english
03/11/2014 20:37 davydavekk#2
You can use std::cin like that :

PHP Code:
std::string savetext;
std::cout << "Enter some text" << std::endl;
std::cin >> savetext// savetext now contains the word entered in the command prompt 
And you should not be using system("pause") to pause your program, use std::cin.get() instead.
03/11/2014 21:06 Mostey#3
I'm not sure if I got this right but you may concatenate both strings:

Code:
std::string str1 = "sometext";
std::string str2 = "anothertext";
std::cout << str1 << std::endl;
std::cout << str2 << std::endl;
std::cout << str1 + str 2 << std::endl // yields "sometextanothertext"
By the way: using namespace std; is not recommended since it can cause compiler errors which eventuelly can't be detected easily.