Newsgroup: comp.lang.c++
Subject: Need Help for printing concatenating string ..
From: ssmile03@...
Date: Sat, 2 Nov 2013 21:25:18 -0700 (PDT)
All,
Need HELP for below wrong output -
---
#include <iostream>
#include <sstream> // for ostringstream
#include <string>
using namespace std;
int main()
{
std::string name = "HELP";
string age = "01";
int count[10];
for (int x = 0; x < 5; x++) {
int result = 5;
result += count[x];
std::ostringstream out;
out << "The value is .." << name << age << result;
std::cout << out.str() << endl;
}
return 0;
}
--
The output is as -
The value is ..HELP012
The value is ..HELP011
The value is ..HELP014198113
The value is ..HELP011
The value is ..HELP011
while the required output should be -
The value is ..HELP011
The value is ..HELP012
The value is ..HELP013
The value is ..HELP014
The value is ..HELP015
Thanks!!
Subject: Need Help for printing concatenating string ..
From: ssmile03@...
Date: Sat, 2 Nov 2013 21:25:18 -0700 (PDT)
All,
Need HELP for below wrong output -
---
#include <iostream>
#include <sstream> // for ostringstream
#include <string>
using namespace std;
int main()
{
std::string name = "HELP";
string age = "01";
int count[10];
for (int x = 0; x < 5; x++) {
int result = 5;
result += count[x];
std::ostringstream out;
out << "The value is .." << name << age << result;
std::cout << out.str() << endl;
}
return 0;
}
--
The output is as -
The value is ..HELP012
The value is ..HELP011
The value is ..HELP014198113
The value is ..HELP011
The value is ..HELP011
while the required output should be -
The value is ..HELP011
The value is ..HELP012
The value is ..HELP013
The value is ..HELP014
The value is ..HELP015
Thanks!!
via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://www.pocketbinaries.com/usenet-forums/showthread.php?120803-Need-Help-for-printing-concatenating-string&goto=newpost
View all the progranning help forums at:
http://www.pocketbinaries.com/usenet-forums/forumdisplay.php?128-Coding-forums
No comments:
Post a Comment