|
>STRTOK関数でもできればSTRTOKのほうがいいんですが、無理ですよね?
なんでstrtokを使うことにこだわるのかよくわかりませんが…
まあ以下のような変態的プログラムが組めないこともないです。
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
char str[]="\t\t\tabc\t\tdef\tghi\t";
char *token, *dummy, *p;
if ( (p = dummy = calloc(sizeof str + 2, 1)) == NULL ) exit(1);
dummy[0] = '*';
strcpy(dummy + 1, str);
while( *(p + 1) ){
token = strtok(p, "\t");
printf("%s\n", token + 1);
*p = '\0';
while(*++p);
*p = '*';
}
return 0;
}
非常に無駄が多いのでこういうものを実際に使ったりしないよーに。
|