I'm programming a program that should use a string which contains
a domain name (f.ex. foo.foocorp.com) and printf the IP address to
stdout using gethostbyname();
This example works nice:
...
if((h=gethostbyname(argv[1])) == NULL)
{
herror("gethostbyname");
exit(1);
}
printf("IP adress: %s\n",inet_ntoa(*((struct in_addr *)h->h_addr)));
...
But how can i replace argv with a string that has previously been
declared with
char String[25]; ?
and later use scanf or cin.
When I try replace argv with pString, the program ends up with a
Segmentation fault..
I ran strace on the program and it reported that the string contained a
newline (\n). (The newline is the error, right? correct me if i'm wrong)
How can i remove this newline? And replace it with a \0 or whatevers
necessary?
--
Torbjoern Kristoffersen <[EMAIL PROTECTED]>