"123",,,"456"..."789"
この場合において123,456,789のダブルクオートで囲まれたものを抽出したい場合
while(pinto,sizeof pinto,fp != NULL){
tp = strchr(pinto,'"');
strcpy(cdmy,strtok(pinto,"\""));
printf(cdmy);
}
これで123は間違いなく取れると思うんですけど
456,789をとりたい場合どうしたらいいでしょうか??
かなり悩んでいましてどなたかお力を貸していただきたく投稿いたしました。
どうぞよろしゅう頼みます。
for文をうまく使い文字を読みきる
Re:for文をうまく使い文字を読みきる
#include <stdio.h> #include <string.h> int main(void) { char str[/url] = "\"123\",\"456\",\"789\""; char *tp; tp = strtok( str, "\"," ); puts( tp ); while ( tp != NULL ) { tp = strtok( NULL,"\"," ); if ( tp != NULL ) puts( tp ); } return 0; }