Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Text labels...

Reply
Thread Tools

Text labels...

 
 
peter_k
Guest
Posts: n/a
 
      11-25-2005
Hi

I was programming a lot in C
When i wanted to make text label i was using something like:

#define MY_PROGRAM_RESULTS "Result of the program = %d\n"
printf(MY_PROGRAM_RESULTS, result);

But this method works only when i use stdio functions... Now i have
started using iostream cout<< and cin>> functions...

In what way should i store text labels (if i want to display few
variables in one line)?

 
Reply With Quote
 
 
 
 
Mike Wahler
Guest
Posts: n/a
 
      11-25-2005

"peter_k" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hi
>
> I was programming a lot in C
> When i wanted to make text label i was using something like:
>
> #define MY_PROGRAM_RESULTS "Result of the program = %d\n"
> printf(MY_PROGRAM_RESULTS, result);
>
> But this method works only when i use stdio functions... Now i have
> started using iostream cout<< and cin>> functions...
>
> In what way should i store text labels (if i want to display few
> variables in one line)?


#include <iostream>
#include <sstream>
#include <string>

const std::string prog_result("Result of the program = ");

int main()
{
int i(42);
std:stringstream oss;
oss << prog_result << i;

std::string text(oss.str());
std::cout << text << '\n'; // prints: Result of the program = 42
return 0;
}

-Mike


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Controlling text in a Text Area or Text leo ASP General 1 12-05-2005 01:13 AM
Encryption from text to text... Kelvin Perl 2 11-09-2004 03:17 PM
Align text in text box acko bogicevic ASP .Net 4 01-09-2004 05:21 PM
Load contents of a text file into a text box Jeremy Chapman ASP .Net 1 08-15-2003 10:10 PM
Display text in text box - should be simple, doesn't work Jim Owen ASP .Net 1 07-24-2003 05:37 AM



Advertisments