Pointer strlen

#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;
char s[] = "Some text";
k=*s
int main ()
{int strlen(char *s);
strlen (k)


}

int strlen (char *s){

int n;
for (n=0; s!='\0'; s++)
n++;
cout<<n;
return 0;
}


I want to test the strlen (with a pointer argument) function on the char array 's'. Could you help me do it? I have tried doing a lot of things but I always get errors. (I saw this strlen decalration in c handbook so it may work differently in c++)
You don't need k. Pass s directly:

strlen (s);

I'd suggest to use more descriptive variable name. Using the same name twice or more isn't a good idea either...


Please use code tags: [code]Your code[/code]
Read this: http://www.cplusplus.com/articles/z13hAqkS/
 
 strlen() 

He needs a char* instead of char**
Here's a possibility
char s[] = "Some text" ----------->char *s
char *s ------------->char **s
Topic archived. No new replies allowed.