再问:关于c++的问题#include
....
string s("hello");
...
请问string 如何set width?(setw是不行的)
You can try this =>
A very intuitive way to do it:
#include<iostream.h>
#include<string>
using std::string;
main(void)
{
string text( "Hello! I want it that way" );
int number=0;
cout << "Please enter the number of characters you want to display"
<< endl;
cout << flush;
cin >> number;
for(int i=0;i<number;i++)
cout<<text[i];
cout << endl;
return 0;
}// end of the source code.
Right now, I don't know any build-in functions to do that. :)
Any way, Good good study, day day up!!!
Cheers!
#include<iostream.h>
#include<string>
using std::string;
main(void)
{
string text( "Hello! I want it that way" );
int number=0;
cout << "Please enter the number of characters you want to display"
<< endl;
cout << flush;
cin >> number;
for(int i=0;i<number;i++)
cout<<text[i];
cout << endl;
return 0;
}// end of the source code.
Right now, I don't know any build-in functions to do that. :)
Any way, Good good study, day day up!!!
Cheers!