前田稔(Maeda Minoru)の超初心者のプログラム入門
![]()
![]()
{ *q= '\0';
strcat_s(des,256,p);
strcat_s(des,256,"purple");
}
p=q+3 //for の中で行っています。
|
/*★ 文字列の検索と置換 前田 稔 ★*/
#include <stdio.h>
#include <string.h>
#include <conio.h>
char sou[]= "red black white red blue gray yellow";
char des[256]= "";
char *p,*q;
void main()
{
for(p=sou; (q=strstr(p,"red"))!=NULL; p=q+3)
{ *q= '\0';
strcat_s(des,256,p);
strcat_s(des,256,"purple");
}
strcat_s(des,256,p);
printf(des);
_getch();
}
|
purple black white purple blue gray yellow |
![]()