50 lines
1.0 KiB
C
50 lines
1.0 KiB
C
/*
|
|
* 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++;
|
|
}
|
|
|
|
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;
|
|
} |