How to make input sentence into one string? or other method?

Hey Guys! I am writing a program on C++ with linux that will require the user to use the program by typing:
./contactadd 12 June 2010 Jessica Daniels Description
It is a contact saver, I think I have the birthday (eg. 12 June 2010) saved and sorted, however I want the name and description to be converted to one string or something like that because I don't know how many words will make up the description.

This is what I have so far:

int main(int argc, char* argv[])
{
saveContact(string(argv[1]) +" "+ string(argv[2]) +" "+ string(argv[3]) +": "+ argv[4]);
}

as you can see the user can only input one word for the description and name.
How could I make it so the user can input as much words for the description as she/he wants?

Thanks!
The join algorithm is what you need.

1
2
3
#include <boost/algorithm/string/join.hpp>
[...]
cout << boost::algorithm::join(vector<string>(argv+1,argv+argc)," ") << endl;
Also, is there a reason you posted this question multiple times? :P
Hey,

It says the "fatal error: boost/algorithm/string/join.hpp: No such file or directory" :(
Sorry..

I posted in beginner first..
and then saw there was a separate linux forum so...
Ill delete the other thread,

you said "argc is the size of the argv array, so you can get the date and such, then loop through the remaining arguments, appending them to a string."

How would I 'loop' them through.. ?

Sorry I am really new to this...
It says the "fatal error: boost/algorithm/string/join.hpp: No such file or directory" :(

Is boost installed properly? If not, download it and extract the boost subdirectory of the archive to your include folder.

How would I 'loop' them through.. ?

Using a loop. See http://www.cplusplus.com/doc/tutorial/control/#loops
Oh, Thanks so much!!
Topic archived. No new replies allowed.