Okay, I've kind of figured out how to take a char array and convert it to a string, but I'm having one problem. I'm using a char array of size 20, but when I convert an array with less than 20 characters I get the string followed by garbage. Like this:

char temp[20];
string word;

word = temp;//temp is filled with input at this point ex:The

cout<<word;

^^^^^this statement gives me:

TheKKKKKKKKKKKKKKKKK//where K=garbage

So my question is how can I just convert the valid contents of the char array to the string instead of the garbage too.