如何将字符串传进指针数组

    1. char* str[100];
    2. char str_tmp[100][100] = { 0 };
    3. for (i = 0; i < n; i++) {
    4. scanf("%s", str_tmp[i]); // 读字符串并传进指针数组
    5. str[i] = str_tmp[i];
    6. }

    对指针指向的字符串进行排序

    1. void Exchange(char* str[], int n) {
    2. char* temp;
    3. int i, j, k;
    4. for (i = 0; i < n - 1; i++) { // 选择排序
    5. k = i;
    6. for (j = i + 1; j < n; j++)
    7. if (strcmp(str[k], str[j]) > 0) k = j;
    8. if (k != i) {
    9. temp = str[i];
    10. str[i] = str[k];
    11. str[k] = temp;
    12. }
    13. }
    14. }