I am thinking of something like:
#include
#include
#include
int main(void) {
//test pointer to string
c
printf("%s\n", ptr);
Is this what you want?
By the way, from printf(3), here's the documentation for the s
conversion specifier (i.e %s
):
If no l modifier is present: The const char * argument is expected to be a pointer to an array of character type (pointer to a string). Characters from the array are written up to (but not including) a terminating null byte ('\0'); if a precision is specified, no more than the number specified are written. If a precision is given, no null byte need be present; if the precision is not specified, or is greater than the size of the array, the array must contain a terminating null byte.