I have this function: int foo(char *string, int x, int y)
Example input is: -.-..-...-. The program tokenises the string with the delimiter -. Then it counts the . in the tokens. The problem is the db variable does not change. After the counting the db has to be higher than x and lower than y. So -.-..-...- 2 3, the solution has to be 2.
char *token;
int length;
int i;
int db=0;
int igaz=0;
int j=1;
token = strtok(string, "-");
length = strlen(token);
while(token != NULL)
{
length = strlen(token);
for(i=0; i<length; i++);
{
if(token[i] == '.')
//if(strcmp(token[i],'.')==0)
{
db++;
}
}
if(db >= x && db <= y)
{
igaz++;
}
db=0;
token = strtok(NULL, "-");
j++;
}
return igaz;
foo()? If so, please fix.;at the end of aforinstruction:for(i=0; i<length; i++);! The following block is only executed wheniis length...