Re: any improvements for this programme
On Jul 23, 6:15 pm, arnuld <geek.arn...@gmail.com> wrote:
On Sun, 22 Jul 2007 13:55:20 -0600, Jerry Coffin wrote:
geek.arn...@gmail.com says...
...[SNIPPED]........
std::copy(std::istream_iterator<std::string>(std::cin),
std::istream_iterator<std::string>(),
std::ostream_iterator<std::string>(temp, " "));
std::string data = std::string(temp.str(),
0,
temp.str().length()-1);
std::cout << data;
return 0;
}
}
this gives error at line: "std::ostringstream temp;"
Try adding: #include <sstream>
up toward the beginning of the file and see if it doesn't help.
yes it works. dinot know that "ostream_iterator" is defined in
"<sstream>" header.
The <sstream> header is for the ostringstream. ostream_iterator
is defined in <iterator>. (But any standard header is allowed
to include any other, and <iterator> is likely included in a
header you've already included.)
BTW, it eats all newlines in the end of input, so i added a
"std::cout << std::endl" just before "return 0", so that the output
doesnot came on the same line as my hostnam eon terminal :-)
You mean that it doesn't generate a final newline on output.
Jerry just forgot that, I suppose. (I've seen shells which
always output an extra newline before the prompt, just to avoid
this problem. The problem then is that you have an extra emptly
line everytime you run a program which works correctly.)
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34