曲径通幽论坛
标题:
找出一个串中的单词"PASCAL"的个数
[打印本页]
作者:
beyes
时间:
2008-11-22 09:58
标题:
找出一个串中的单词"PASCAL"的个数
#include <stdio.h>
#include <string.h>
int
main
(
void
)
{
char
str[
500
];
const
char
*
ptr
=
"pascal"
;
char
*
ptr_t
=
(
void
*
)
NULL
;
int
count
=
0
;
printf(
"please input a string:
\n
"
);
scanf(
"%s"
,str);
while
( ( ptr_t
=
strstr( str,ptr ))
!=
NULL
){
count
+=
1
;
ptr_t
=
ptr_t
+
6
;
strcpy( str, ptr_t );
}
printf(
"pascal count is %d
\n
"
,count );
return
0
;
}
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/)
Powered by Discuz! X3.2