Just add a 'continue' instruction over the ',' char and a flag 'find' when you find the correct char :
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char str1[] = "a,s,e,d,8,f";
char str2[] = "1,2,3,4,5,6,7,8,9,0";
int i, j, len1, len2, find = 0, con = 0;
len1 = strlen(str1);
len2 = strlen(str2);
for (i = 0; i < len1; i++)
{
if(str1[i]==',')
continue;
for (j = 0; j < len2; j++)
{
if (str1[i] == str2[j])
{
find = 1;
break;
}
}
con++;
if(find>0)
break;
}
printf("%d\n", con);
}