阅读背景:

只有令牌的第一个字符存储在c ++中的数组中

来源:互联网 
    int main(void)
{
char *text = (char*)malloc ( 100 *sizeof( char));
cout << "Enter the first arrangement of data." << endl;
cin.getline(text, 100);
char *token = strtok(text, " ");
char *data = (char*)malloc ( 100*sizeof( char));
while ( token != NULL )
{
    if (strlen(token) > 0)
    {
        cout << token << endl; // to test if the token is correct so far.
        data[Tcount++] = *token;
    }
    token = strtok(NULL, " ");
}


for(i = 0; i < Tcount; i++)
{
    cout << data[i] << endl;
}  
    int main(void)
{
char *text = (char*)malloc



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: