Simple but I forgot...
-
BODY, P, TD { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt } H2,H3,H4,H5 { color: #ff9900; font-weight: bold; } H2 { font-size: 13pt; } H3 { font-size: 12pt; } H4 { font-size: 10pt; color: black; } PRE { BACKGROUND-COLOR: #FBEDBB; FONT-FAMILY: "Courier New", Courier, mono; WHITE-SPACE: pre; } CODE { COLOR: #990000; FONT-FAMILY: "Courier New", Courier, mono; }
I am fairly new to Visual C++ Programming but I have experience in C. I want to display the content of a string in a string.
Printf("Welcome %s.", name);
, in C, I did it like this but in Visual C++, I have a stringm_strWelcome
and I want to displaym_strName
in it like above. How? // JS Paquet cout << "Thank you all" << endl; -
BODY, P, TD { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt } H2,H3,H4,H5 { color: #ff9900; font-weight: bold; } H2 { font-size: 13pt; } H3 { font-size: 12pt; } H4 { font-size: 10pt; color: black; } PRE { BACKGROUND-COLOR: #FBEDBB; FONT-FAMILY: "Courier New", Courier, mono; WHITE-SPACE: pre; } CODE { COLOR: #990000; FONT-FAMILY: "Courier New", Courier, mono; }
I am fairly new to Visual C++ Programming but I have experience in C. I want to display the content of a string in a string.
Printf("Welcome %s.", name);
, in C, I did it like this but in Visual C++, I have a stringm_strWelcome
and I want to displaym_strName
in it like above. How? // JS Paquet cout << "Thank you all" << endl;CString has this nice method called
Format()
that works just likesprintf()
:CString strName = "Josh";
CString strWelcome;
strWelcome.Format("Welcome %s.", strName);Or you could do:
CString strName = "Josh";
CString strWelcome = "Welcome " + strName + '.';Your preference :) farewell goodnight last one out turn out the lights
Smashing Pumpkins, Tales of a Scorched Earth
-
BODY, P, TD { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt } H2,H3,H4,H5 { color: #ff9900; font-weight: bold; } H2 { font-size: 13pt; } H3 { font-size: 12pt; } H4 { font-size: 10pt; color: black; } PRE { BACKGROUND-COLOR: #FBEDBB; FONT-FAMILY: "Courier New", Courier, mono; WHITE-SPACE: pre; } CODE { COLOR: #990000; FONT-FAMILY: "Courier New", Courier, mono; }
I am fairly new to Visual C++ Programming but I have experience in C. I want to display the content of a string in a string.
Printf("Welcome %s.", name);
, in C, I did it like this but in Visual C++, I have a stringm_strWelcome
and I want to displaym_strName
in it like above. How? // JS Paquet cout << "Thank you all" << endl;If you're using a string class like the STL string or MFC CString you can use the overloaded operators to concatenate two strings, i.e. m_strWelcome = _T("Welcome ") + m_strName. The MFC CString class does provide a Format() function which works similar to printf() to format a string. Justin Neville
-
BODY, P, TD { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt } H2,H3,H4,H5 { color: #ff9900; font-weight: bold; } H2 { font-size: 13pt; } H3 { font-size: 12pt; } H4 { font-size: 10pt; color: black; } PRE { BACKGROUND-COLOR: #FBEDBB; FONT-FAMILY: "Courier New", Courier, mono; WHITE-SPACE: pre; } CODE { COLOR: #990000; FONT-FAMILY: "Courier New", Courier, mono; }
I am fairly new to Visual C++ Programming but I have experience in C. I want to display the content of a string in a string.
Printf("Welcome %s.", name);
, in C, I did it like this but in Visual C++, I have a stringm_strWelcome
and I want to displaym_strName
in it like above. How? // JS Paquet cout << "Thank you all" << endl;i dunno if this is the best way since im a newbie too.. but heres how i've been doing it so far CString strTemp; CString strName("dzgraphics.com"); strTemp.Format("I really like %s",strName); AfxMessageBox(strTemp); -dz
-
CString has this nice method called
Format()
that works just likesprintf()
:CString strName = "Josh";
CString strWelcome;
strWelcome.Format("Welcome %s.", strName);Or you could do:
CString strName = "Josh";
CString strWelcome = "Welcome " + strName + '.';Your preference :) farewell goodnight last one out turn out the lights
Smashing Pumpkins, Tales of a Scorched Earth
-
BODY, P, TD { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt } H2,H3,H4,H5 { color: #ff9900; font-weight: bold; } H2 { font-size: 13pt; } H3 { font-size: 12pt; } H4 { font-size: 10pt; color: black; } PRE { BACKGROUND-COLOR: #FBEDBB; FONT-FAMILY: "Courier New", Courier, mono; WHITE-SPACE: pre; } CODE { COLOR: #990000; FONT-FAMILY: "Courier New", Courier, mono; }
I am fairly new to Visual C++ Programming but I have experience in C. I want to display the content of a string in a string.
Printf("Welcome %s.", name);
, in C, I did it like this but in Visual C++, I have a stringm_strWelcome
and I want to displaym_strName
in it like above. How? // JS Paquet cout << "Thank you all" << endl;I'm not suer if the other posts answered your question. They discuss formatting, but not printing. Assuming m_strWelcome is a CString... Printf("Welcome %s.", LPCSTR(m_strWelcome));, Good luck., Bill