// Recursive Length of String
#include <stdio.h>
#include <string.h>
intgetlength (const char *);
int main ()
{
char text [] = "Hello, World";
printf ("String: %s\nLength: %d\nStrlen: %d\n\n", text, getlength (text), strlen (text));
return 0;
}
intgetlength (const char * s)
{
if (s == NULL || *s == '\0')
return 0;
else
return 1 + getlength (s + 1);
}
#include <stdio.h>
#include <string.h>
intgetlength (const char *);
int main ()
{
char text [] = "Hello, World";
printf ("String: %s\nLength: %d\nStrlen: %d\n\n", text, getlength (text), strlen (text));
return 0;
}
intgetlength (const char * s)
{
if (s == NULL || *s == '\0')
return 0;
else
return 1 + getlength (s + 1);
}
No comments:
Post a Comment