Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 22:32

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



help c++

Discussion on help c++ within the C/C++ forum part of the Coders Den category.

Reply
 
Old   #1
 
_Entropia_'s Avatar
 
elite*gold: 0
Join Date: Apr 2012
Posts: 44
Received Thanks: 119
help c++

hi guys.
my problem is this,How can I assign all letters printed of the console in "string savetext;".

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
_Entropia_ is offline  
Old 03/11/2014, 20:37   #2
 
davydavekk's Avatar
 
elite*gold: 0
Join Date: May 2013
Posts: 101
Received Thanks: 42
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.
davydavekk is offline  
Thanks
1 User
Old 03/11/2014, 21:06   #3


 
elite*gold: 1091
Join Date: Jun 2007
Posts: 19,836
Received Thanks: 7,180
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.
Mostey is offline  
Thanks
1 User
Reply




All times are GMT +1. The time now is 22:33.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.