Is a void * equivalent to a char *?
- From: planetzoom <fox@xxxxxxx>
- Date: Wed, 07 Feb 2007 06:23:03 GMT
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?
.
- Follow-Ups:
- Re: Is a void * equivalent to a char *?
- From: Keith Thompson
- Re: Is a void * equivalent to a char *?
- From: Harald van Dijk
- Re: Is a void * equivalent to a char *?
- From: Walter Roberson
- Re: Is a void * equivalent to a char *?
- Prev by Date: Re: [OT] Re: static, global variable memory allocation
- Next by Date: Re: [OT] which hash table - chained or open-addressed? - TPA
- Previous by thread: lex
- Next by thread: Re: Is a void * equivalent to a char *?
- Index(es):
Relevant Pages
|