-2
#include<stdio.h>
void main()
{
char source[30]="salai word2 word3";
char destination[20][20];
printf(" \n\source is: %s\n\n", source);
getch();
}
在上述程序中,char變量「source」包含三個單詞(用空格分隔)。我如何從「源」中讀取單詞並將其存儲在另一個字符數組「目標」中。期望如下:C程序 - 如何從字符串中逐個字符地讀取字符
strcpy(destination[0], salai)
strcpy(destination[1], word2)
strcpy(destination[2], word3)
和'strtok()',也許 –
這個「怎麼樣」太寬了,VTC。此外,顯示你的努力,直到時間。, –
看到這一個 http://stackoverflow.com/questions/9210528/split-string-with-delimiters-in-c – Hast