Hi,
I wanted to avoid the hard coding of IP Address in my implementation using standard C. Instead I want to pass it so that I can connect to different remote hosts. Any example of how I can do this.
Regards
Printable View
Hi,
I wanted to avoid the hard coding of IP Address in my implementation using standard C. Instead I want to pass it so that I can connect to different remote hosts. Any example of how I can do this.
Regards
On the command line:Quote:
ViggyCode:myApp.exe 128.146.12.10
#include <stdio.h>
int main(int argc, char *argv[])
{
if (argc != 2)
{
printf("\n Wrong arguments.. Enter ip address.");
}
char *printerIP;
printerIP = argv[1];
printf("\n printerIP is %s ",printerIP);
getchar();
return 0 ;
}
What if you have a long list of remote IP addreses you want to connect ? I agree hardcoding takes time and mind to deal with. What application are you working on, actually ? Because I think sometimes it depends on the actual modules you try to implement too so you need to be a little choosey for which method is more appropriate.Quote:
There's no need for hardcoding
- Enter on the command line
- Enter into a list box (GUI)
- Enter into a side file
These are just a few alternatives.
Viggy