示例程序:
#include#include #include #include using namespace std; int main() { char const *data = "hello1123456789"; int datasize = strlen(data); char cmd[9]; for(int i=0; i<9;i++) { cmd[i] = data[i+6]; cout << cmd[i] << endl; } cmd[strlen(cmd)] = ' '; //cmd[strlen(cmd)] = 0; 这样也可以 cout << cmd << endl; cout << 1 << endl; return 0; }
输出结果如下:
$g++ -o main *.cpp $main 1 2 3 4 5 6 7 8 9 123456789 1



