Digital-Systems-Assignments/Assignment 9/main.c

56 lines
1.1 KiB
C
Raw Permalink Normal View History

/*
* 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++;
}
// for (i =0; i < sringlenth; i++){ aa
baaaab
if (thestring[i:i+5])
}
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;
}