answersLogoWhite

0


Best Answer

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

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

10y ago

function

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you use strlen function in c language?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Why use length function to find length of primitive data type array object?

There is no length function in C. You may have thought of sizeof or strlen. Perhaps.


What is library function in C programming?

printf, fgets, strlen, malloc etc


Why you use 'integer' before function in C language?

To specify the return-type of the function.


What function is used to perform exponentiation in C language?

You can use the pow() function in math.h.


Why you use else function in c language?

You cannot have a function named else, because it is a reserved word.


How you can convert from string to int in C language?

Use the atoi() or atol() function.


What is the use of gets function in c language?

Nothing, it is a security hole. Use 'fgets' instead.


What is the differnce between ordinary function and template function of c language?

The c language does not have template functions. That is a c++ thing.


Why you are using clrscr in c language?

Function 'clrscr' is not part of the C language. Or the standard libraries. It is MS-DOS specific function, use the help for details (clrscr means clear the screen).


How do you use cosine in c language?

Include the header file math.h and use the function acos(d)


Why use setcolor function in c graphics?

C language doesn't say anything about graphics, it is platform-dependent.


How do you createe a file using c language?

Use function open or creat or fopen.