checking for suffix

+1 J show · March 6, 2015
int isStrSuffix(char str1[], char str2[])

{

int sub, j=0, k=0, k1=0;



sub = strlen(str1) - strlen(str2);



while(str1 != '\0')

{

if(str1 == str2[j])

{

sub++;

j++;

k1=1;

}

if(j=1)

{

j=0;

k=1;



}

else

{

if(k1==1)

{

j = 0;

k1 = 0;

}

else

sub++;

}

}

if(k==1)

return 1;

else

{

if(k==0)

return 0;

}

?





}

Cant figure out why this wont check for suffix and return a value?

Post a Reply

Replies

Oldest  Newest  Rating
0 J show · March 6, 2015
int isStrSuffix(char str1[], char str2[])
{
int sub, j=0, k=0, k1=0;
 sub = strlen(str1) - strlen(str2);
 while(str1 != '\0')
{
if(str1 == str2[j])
{
sub++;
j++;
k1=1;
}
if(j=1)
{
j=0;
k=1;
 }
else
{
if(k1==1)
{
j = 0;
k1 = 0;
}
else
sub++;
}
}
if(k==1)
return 1;
else
{
if(k==0)
return 0;
}

?
 }
0 J show · March 6, 2015
Don know why it looks so small either ahah
0 c student · March 7, 2015
try using a different variable in place of sub
0 J show · March 10, 2015
I think i figured out the suffix part but Thanks for the help tho.
  • 1

C

107,075 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator