What type of variable does one use when it's an ip address?
like Float, Double, Int, String, whatever. for a 192.168.1.1 piece of info? Thanks in advance.
What type of variable does one use when it's an ip address?
like Float, Double, Int, String, whatever. for a 192.168.1.1 piece of info? Thanks in advance.
I really prefer not to use an array, if possible. What one should I use if I don't?
An int should be ok if you are on systems where an int is at least 32-bits. String should be safe.
Well, if you're trying to do something silly like this:
That's rather silly and it's no wonder it fails. Just use a string unless you're doing actual net coding.Code:int x = "192.168.1.1";
It is pretty silly what I am doing. Thanks for the reply. One last question, if you wouldn't mind?
I was unable to find this anywhere:
How do you start a program with c++? I found delete, I found textfile opening, and all that stuff, but nowhere how to make it open a .exe file. It is possible, I assume.
You want your program to open (execute) another program? What OS? ShellExecute perhaps... one of the spawn family of functions... numerous others (system if you're desperate). Check the FAQ.
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens
Windows XP. Like, add options to a program so you can start other stuff. Like Ping.exe with parameters and all kinda other stuff from one base program. I know it's simple. I know it's stupid. But I'd really like to know how. =) So, "ShellExecute" should work? What's it's usage? ShellExecute ("C:\Windows\system32\ping.exe") ?
CreateProcess() or CreateProcessEx()... I can't remember. Those are the "proper" ways of doing it on Windows.
Well, this is slowly becoming a not so quick question. Oops.
This is my code:
It gives the error:Code:#include <cstdlib> #include <iostream> #include <windows.h> using namespace std; int main() { string a; string b; string c; cout << "Please Enter The I.P. Address: "; cin >> a; "\n"; cout << "Please Enter any Parameters you wish to include (example: -t -l): "; cin >> b; "\n"; cout << "Please enter the byte number you wish to send (0-65500): "; cin >> c; "\n"; ShellExecute ("C:\windows\system32\ping.exe"); system("PAUSE"); return EXIT_SUCCESS; }
Help please?19:18 C:\Dev-Cpp\asdasd.cpp [Warning] unknown escape sequence '\w'
19:19 C:\Dev-Cpp\asdasd.cpp [Warning] unknown escape sequence '\s'
19:19 C:\Dev-Cpp\asdasd.cpp [Warning] unknown escape sequence '\p
C:\Dev-Cpp\asdasd.cpp In function `int main()':
19 C:\Dev-Cpp\Project.cpp cannot convert `const char*' to `HWND__*' for argument `1' to `HINSTANCE__* ShellExecuteA(HWND__*, const CHAR*, const CHAR*, const CHAR*, const CHAR*, INT)' '
C:\Dev-Cpp\Makefile.win [Build Error] [Project.o] Error 1
Don't type random crap. Use google + MSDN.
http://msdn2.microsoft.com/en-us/library/bb762153.aspx
(edit2:, macgyver beat me to it )
http://msdn2.microsoft.com/en-us/library/bb762153.aspx
If you just want the simple version though:
I think that opens a telnet connection on XP, I may be wrong though.Code:ShellExecute(NULL, "open", "C:\\windows\\telnet.exe", "-o 127.0.0.1", SW_SHOW);
However, if all you want to do is ping or something you can probably use system() calls for simplicity.
I may be wrong none of this code is tested but I think that works.Code:string myString = "ping 127.0.0.1"; system(myString.c_str()); // I think you need to pass this as a cstr for system?
EDIT:
Note your errors, you need to use \\ instead of \ due to escape characters. IE: \windows needs to be \\windows or else the computer thinks you want to use whatever "\w" is as a code.
Last edited by tjpanda; 10-16-2007 at 06:50 PM.
"When your work speaks for itself - don't interrupt!"
-Samantha Ingraham.
You can fiddle all you want, but if you're going to ask for help, then make your attempts serious. Otherwise, you're just begging for us to do your research for you.