#include <stdio.h>
#include <string.h>
int main()
{
char aaavalue[1024] = {"ABC,DEFG,Aabcdef,gaAdD,AW"};
char bbbvalue[1024];
char cccvalue[1024];
char *argvalue[5];
char *pos = bbbvalue;
strcpy(bbbvalue
,aaavalue
); //コピーしておく strcpy(cccvalue
,aaavalue
); //コピーしておく
printf("%s\n", aaavalue
); //そのまま出力。。したつもり。。 printf("%s\n", bbbvalue
); //置換前そのまま出力 while ((pos
= strchr(bbbvalue
, ','))!=NULL
) *pos
= '\n'; printf("%s\n", bbbvalue
); //置換して出力
int i = 0;
argvalue
[i
] = strtok(cccvalue
, ","); if (argvalue
[i
] != NULL
) printf("%s\n", argvalue
[i
]); while (argvalue[i] != NULL) {
argvalue
[++i
] = strtok(NULL
, ","); if (argvalue
[i
] != NULL
) printf("%s\n", argvalue
[i
]); }
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KCmludCBtYWluKCkKewogICAgY2hhciBhYWF2YWx1ZVsxMDI0XSA9IHsiQUJDLERFRkcsQWFiY2RlZixnYUFkRCxBVyJ9OwogICAgY2hhciBiYmJ2YWx1ZVsxMDI0XTsKICAgIGNoYXIgY2NjdmFsdWVbMTAyNF07CiAgICBjaGFyICphcmd2YWx1ZVs1XTsKICAgIGNoYXIgKnBvcyA9IGJiYnZhbHVlOwogICAgc3RyY3B5KGJiYnZhbHVlLGFhYXZhbHVlKTsgLy/jgrPjg5Tjg7zjgZfjgabjgYrjgY8KICAgIHN0cmNweShjY2N2YWx1ZSxhYWF2YWx1ZSk7IC8v44Kz44OU44O844GX44Gm44GK44GPCiAgICBzdHJ0b2soYWFhdmFsdWUsIiwiKTsKCiAgICBwcmludGYoIiVzXG4iLCBhYWF2YWx1ZSk7IC8v44Gd44Gu44G+44G+5Ye65Yqb44CC44CC44GX44Gf44Gk44KC44KK44CC44CCCiAgICBwcmludGYoIlxuIik7CiAgICBwcmludGYoIiVzXG4iLCBiYmJ2YWx1ZSk7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