How to allocate memory to a string in C?

hi
I want to take string as a input from user and the string is very very length. From the lengthy string i have to substring take first 16 letters, then next 8 letters,................... Please guide me how to write program to take lengthy string from user and sub string it.
Thanks

The string is what? I don't understand.

How is this different from taking the first 24 letters?

Your question is not clear. Try to post your code. So that we can see what is wrong in that and then correct it.

check this website
Substring(start, end, str) in c - Dev Shed

hi
Here is the working code
/* This method takes String, Start Length and End Length as input parameters, sub string the string and returns it */

char* getsubstring(const char* urstr, size_t beginL, size_t len)
{
if (urstr == 0 || strlen(urstr) == 0 || strlen(urstr) < begin || strlen(urstr) < (beginL+len))
return 0;
return strndup(urstr + beginL, len);
}

Thanks