Sunday, August 2, 2009

C++, How do you input into a char array from the keyboard?

i want to input char array using keyboard,and what is the number of char unknown.. can i

C++, How do you input into a char array from the keyboard?
#include %26lt;string%26gt;


#include %26lt;iostream%26gt;





int main()


{


string myStr;


cin %26gt;%26gt; myStr; // use this if you want one word


cin.getline(myStr); //use this if you want one line don't use both


char myCharArray{}=myStr.c_str();


}





/* myCharArray now contains a character array of either one word or one line */


No comments:

Post a Comment