Checking it character by character is not necessary when you already have a function like strstr() to do the job of searching a string in an array.
However if you need to do it character by character, you can try it this way, you could try it this way ... this is the longer version, you could use loop within a loop...
i = 0
while (str[i]!= '\0')
{
if (str[i] == '.')
{
//asuming that after filename.txt its end of string ie '\0' character)
if (str[i+1] == 't' && str[i+2] == 'x' && str[i+3] == 't' && str[i+4] == '\0')
{
printf("\ntxt extension found");
break;
}
i++; //so that next character can be checked.
}
Hope this helps
hai guys....i have question about array...let say i have a filename newfile.txt..i want to check the file extension...if the extension is .txt then i'll store it otherwise i'll remove...i already have an idea...i want to check character by character...do someone have an example for this?