-
While - if - pointers...
Ok. Here, i want to know, in the first 'while', it starts with first char, so we have for ex. 'a'. Then the word, second 'while', it starts with first char and we have ex. 'b'. I want to compare them, want to compare two words. Then 'if' comes. If 'if' is true, br++. Where does it goes next, does it runs until second 'while' is finished or what? It should be running second 'while' until '\0', and every time char is the same as first char of '*po2' it should do 'br++', but of course it doesnt work.
po2=sentence;
po1=word;
Code:
while(*po2!='\0')
{
while(*po1!='\0')
{
if(*po1==*po2)
{
br++;
}
po1++;
}
}
printf("%d", br);
-
You aren't incrementing po2 anywhere, the outermost while loop will be an infinite loop.
-
well, i did move a little bit now...thx