summaryrefslogtreecommitdiff
path: root/src/c/string/strcspn/gstrcspna.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/c/string/strcspn/gstrcspna.c')
-rw-r--r--src/c/string/strcspn/gstrcspna.c45
1 files changed, 18 insertions, 27 deletions
diff --git a/src/c/string/strcspn/gstrcspna.c b/src/c/string/strcspn/gstrcspna.c
index 4dcdcdf..91de8af 100644
--- a/src/c/string/strcspn/gstrcspna.c
+++ b/src/c/string/strcspn/gstrcspna.c
@@ -14,37 +14,28 @@
#include "strcspn.h"
uint8 gstrcspna(char *str1,int size1,char *str2,int size2)
{
- int ind,i,j;;
-
- for(i=0;i<=size1;i++)
+
+ uint8 ind=size1+1;
+ int l,m;
+ for(m=0;m<size2;m++)
{
- for(j=0;j<=size2;j++)
- {
- if(str2[j]==str1[i])
+ int tp;
+ for(l=0;l<size1;l++)
{
- ind=j;
- break;
+ if(str2[m]==str1[l])
+ {
+ tp=l;
+ if(ind>tp)
+ {
+ ind=tp;
+ }
+ }
}
- }
}
- return (ind+1);
-}
-/*int main()
-{
- int n1,n2;
- char inp1[100000],inp2[100000];
- printf("Enter the length of the first string");
- scanf("%d",&n1);
- for(int i=0;i<=(n1+1);i++)
- {
- scanf("%c",&inp1[i]);
- }
- printf("Enter the length of the second string");
- scanf("%d",&n2 );
- for(int j=0;j<=(n2+1);j++)
+ if(ind==size1+1)
{
- scanf("%c",&inp2[j]);
+ ind=size1;
}
- strcspnfn(inp1,n1+1,inp2,n2+1);
+ return ind;
}
-*/
+