title: How to capture ping's return value in C++
body: <p>Does anyone know, how to capture ping's return value in c++? According to this <a href="http://docs.hp.com/en/B2355-60105/ping.1M.html" rel="nofollow noreferrer">link</a>:
  ping should return <code>0</code> on success, <code>1</code> on failure such as unknown host, illegal packet size, etc. and <code>2</code> On a unreachable host or network. </p>
  
  <p>In C++ I called ping with the <code>system ()</code>, e.g. <code>int ret = system("ping 192.168.1.5");</code>.</p>
  
  <p>My problem is, that <code>ret</code>'s value is <code>0</code> or <code>1</code>. It will never <code>2</code>! If I think correctly, this is because, this return value I get, is the system functions return value, not ping's. So how could i get ping's return vlaue?</p>
  
  <p>Thanks in advance!</p>
  
  <p>kampi</p>
  
  <p>Edit:
  Right now i use this system("ping 192.169.1.5 > ping_res.txt"); but i don't want to work with files (open, and read them), that's why i want to capture, th return value , if possible :)</p>