#include
#include
int strlen(char *s)
{
int n;
for(n=0;*s!='\0';s++)
n++;
return n;
}
int main()
{
/*char s[] = "JohnBridge my Heart";
printf("length = %d\n",strlen(s));
*/
int n;
char *s;
n = strlen("JohnBridge my Heart");
s = (char *)malloc(n*sizeof(char));
*s = "JohnBridge my Heart";
printf("length = %d\n",strlen(s));
return 0;
}
Malloc in C
Posted by acas arnel m. at 12:46 AM
Labels: C language codes
Subscribe to:
Post Comments (Atom)
2 comments:
it was good enough!
thanks that ur blogsite was usefull to us.
Post a Comment