Ping?

Can someone right me a program where user enters ip then the prompt window in visual studio c++ displays the ping info?
thanks
Is this a joke?
50$
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include <string>
using namespace std;

int main(){
  string input = "";
  cout << "type \"ip\"";
  cin >> input;
  cout << "the ping info?";
  return 1; //SUCCESS!!! =]
}
Last edited on
I loled

The word "write" is not spelled as right. Check your grammar....


Last edited on
What info do you need? Is it just the info that you get when you type "ipconfig" into the windows command prompt

using the "system" command is the only way I can think of right now, although I'm sure there are better ways. Everyone that programs seems to hate system and not without reason: http://www.cplusplus.com/forum/articles/11153/

I'm not aware of anyway to read in the input directly from system. So you might have to write it to a text file or something, then read it from there. If your doing it this way, you'll want to use the system command with something along the lines of "ipconfig > ip_info.txt" then read in the info from that text file, and do whatever you want with it.

As I say though, there is almost certainly a better way of doing this than what I just said. And if all your intending to do is ask people in forums would they right it for you, then you have no chance.
As I say though, there is almost certainly a better way of doing this than what I just said. And if all your intending to do is ask people in forums would they right it for you, then you have no chance.
Look at the post above you!

A system command wouldn't be the end of the world in a program like this. What bothers me is just when people use system("pause"); when getchar() is so much easier and more efficient? Why is there a need to call the operating system to read a single character of input? When performing a less mundane task, without another clear solution, it wouldn't be too much of a problem. So in this case if our good OP wants to I say go for it :)
Haha, I don't think I've confused write and right for about 15 years.

Yea it's good to hear you say that about system(), it was much what I was thinking as well.

(by the way, this is the same Meerkat, I tried to change my name, then I tried to delete my old account, but couldn't seem to do either. Are you able to do either?)
Hmm, I'm not sure. I'd contact an admin.
Topic archived. No new replies allowed.