Is a void * equivalent to a char *?



Given the following code:

#include <stdio.h>

int main(void)
{
char array[100] = "What is your favorite car?";
void *vp = &array;

printf("%s\n", vp);

return 0;
}

Is the printf() statement correct? Or is a cast to char * required for vp?

printf("%s\n", (char *) vp);

That is, assuming a void * is pointing to a string, what is the proper way
to print the string?
.



Relevant Pages

  • Re: tree example
    ... understand the tree example but no what I just memtioned. ... The only occurrence of the string "(char *)" in page 143 is a cast ... acknowledge that malloc and it siblings do not need this type of cast. ...
    (comp.lang.c)
  • Re: Problems with (Cast)
    ... >> Why I'm getting this error when I try to cast as char? ... I wouldn't expect a single-character string to cast to ... > type of obj if it still doesn't work: ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Problems with (Cast)
    ... > Why I'm getting this error when I try to cast as char? ... I wouldn't expect a single-character string to cast to ... type of obj if it still doesn't work: ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Comment on trim string function please
    ... I've not been following why the cast is important; ... Serious bug. ... unsigned char. ... I appear to "getting" a signed 8-bit integer value from my string, ...
    (comp.lang.c)
  • Re: Is a void * equivalent to a char *?
    ... Is the printf() statement correct? ... The cast is probably not actually required in this special case, ... Convert vp to char *, ...
    (comp.lang.c)