Please can anyone help me on strlen, strcmp , strcpy, strcat...

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
Have you looked at the definitions of those functions?

Why do your versions stop at 100 comparisons?
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
NVM got it
and yes I did look at definition which I really don't get
Well, you have to get it if you are to reproduce their functionality.

What is it you didn't understand?
Haha,, if i get it would I even post this in the first place?
Topic archived. No new replies allowed.