2019-10-24 14:17:22 +00:00
|
|
|
/*
|
|
|
|
* Student: S.K. Soekhlal
|
|
|
|
* Number: 4860632
|
|
|
|
* Assignment: 4.8
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
char str[1024];
|
|
|
|
int slen, wlen, count, i, j;
|
|
|
|
|
|
|
|
void next(){
|
|
|
|
while(isspace(str[i]) == 0 && ispunct(str[i] == 0 && str[i] != '\0'))
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2019-10-24 20:04:27 +00:00
|
|
|
// for (i =0; i < sringlenth; i++){ aa
|
|
|
|
baaaab
|
|
|
|
if (thestring[i:i+5])
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-10-24 14:17:22 +00:00
|
|
|
int main(int argc, char **argv){
|
|
|
|
gets(str);
|
|
|
|
slen = strlen(str);
|
|
|
|
printf("%d\n", slen);
|
|
|
|
wlen = strlen(argv[1]);
|
|
|
|
printf("%d\n", wlen);
|
|
|
|
for (i = 0; i < slen; i++){
|
|
|
|
}
|
|
|
|
i = j = count = 0;
|
|
|
|
while(i < slen){
|
|
|
|
if (str[i] == *argv[1]){
|
|
|
|
for (j = 0; j < wlen; j++){
|
|
|
|
if(str[i+j] != argv[1][j]){
|
|
|
|
next();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (j == wlen){
|
|
|
|
if (isspace(str[i+j]) || ispunct(str[i+j]) || str[i+j] == '\0'){
|
|
|
|
count++;
|
|
|
|
i +=j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
next();
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
printf("%d\n", count);
|
|
|
|
return 0;
|
|
|
|
}
|