May 24, 2015 at 8:43pm UTC
I Edited my question
1. This is what i have and one below is testing code
1 2 3 4 5 6 7 8 9 10 11
int mystrlen(const char *s)
{
int x=0;
for (int i = 0; i < 100; i++)
{
if (s[i] != '\0' )
x++;
}
return x;
}
1 2 3 4 5 6 7 8 9 10 11 12 13
void testmystrlen(void )
{
size_t uiResult;
uiResult = mystrlen("Ruth" );
ASSURE(uiResult == 4);
uiResult = mystrlen("Gehrig" );
ASSURE(uiResult == 6);
uiResult = mystrlen("" );
ASSURE(uiResult == 0);
}
I can't use s.size() since its address which is why I get bigger number than 20
for ruth and ""
is there way to fix this?
Last edited on May 24, 2015 at 9:56pm UTC
May 24, 2015 at 9:44pm UTC
Have you looked at the definitions of those functions?
Why do your versions stop at 100 comparisons?
May 24, 2015 at 9:49pm UTC
testing my own let me edit my thing... i didn't know there was test cpp file ...
and i am suppose to create my own...
and yes I did look at definition which I really don't get
Last edited on May 24, 2015 at 9:51pm UTC
May 25, 2015 at 1:30am UTC
Haha,, if i get it would I even post this in the first place?