answersLogoWhite

0

It is very difficult, because it has as many as oneparameter, so it is very easy to get confused...

try this:

const char *s= "example";

printf ("length of '%s' is %d\n", s, (int)strlen (s));

strlen just tells you how many charters there are before the the first zero value. If you are going to create a buffer based on strlen then you must add 1 to the value that strlen returnes. The needs to be a place to store the terminating zero.

char *s= "example";

char *buffer;

buffer = (char*)malloc(strlen(s)+1);

User Avatar

Wiki User

14y ago

What else can I help you with?