ok so basically i just wanted to know how to add a string variable between text..

eg.

string name;

cout << "Hello,"name"sucks";

i want to know how to do it all in one line since where i use it there are parameters and they don't allow me to make another line like cout.

thnx.

Do you mean like this?

string name = "Billy Bob";
cout << "Hello " << name << " you're a wonderful person..." << endl;

yea that's what i meant but i said not only with cout.. well here's an example of where i'd like to use it.

string name;

MessageBox(NULL,"Error"name"sucks","error",MB_ICONEXCLAMATION);

i can't use cout style there.. so how do i use it in such parameters?

How about:

std::string message = "Error "+ name + " sucks";
MessageBox(NULL,message.c_str(),"error",MB_ICONEXCLAMATION);

ahhh! we meet again smarty pants :P

soon i shall be proer than you :)

and...
thnx :D

ahhh! we meet again smarty pants :P

If you don't want my replies, just say the word. :icon_wink:

Nevermind, see you already have a nice answer. I guess I took too long on the response... hehehe... I was thinking you were doing command line and not a Windows GUI program so my suggestion was going to be c style printf()... but I see that's not quite what you were looking for.

#include <cstdio>
printf("Hello, %s. How are you?", "Billy Bob");

HEY HEY!!! NIEK!!

i was just messin with u...

sry if i offended you D:

sry if i offended you D:

You're going to have to try a lot harder to offend me. I was just kidding off course :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.