Reputation: 3163
I have a piece of code that use gethostbyname() function, which is defined this way:
struct hostent *gethostbyname(const char *name);
My question is very simple, is it possible to directly put the char value like this :
gethostbyname("10.11.22.4");
or do I have to do it like:
char *tab[10];
gethostbyname(*tab);
or, is it another way ?
Thanks
Upvotes: 0
Views: 289
Reputation: 12837
As said here the type of a string literal "this is a string literal" is an array of const char
. Arrays decay to pointers, so this means you can use
gethostbyname("10.11.22.4");
without declaring it first
Upvotes: 1