|
Im trying to make a program that will ping an ip and then i will play with the output to then log it to a file. My problem is this is new to me hehe and i have no clue how to call a variable in the function system();
This is what i have up to now
<code>
#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
string ip;
cout << "Welcome to test app";
cout << "\nEnter an ip: ";
cin >> ip;
cout << "\nGonna try to ping " << ip << "\n";
char output [100];
system("ping -c 2 ", ip);
cin.getline(output,100);
cout << output;
return 0;
}
</code>
Now the line system("ping -c 2 ", ip); definatly doesnt work and that is where im stuck atm. ANd it is hard to search on google when you have system as keyword hehe.
Anyone can gimme a hand?
Thanks
|
|
|
|
|
MrJake wrote:
Im trying to make a program that will ping an ip and then i will play with the output to then log it to a file.
Yuck! Why use such an antiquated method when a direct approach is much simpler? The ICM protocol is easily Googled and there are several examples here at CP on how to make a ping-like application. The last time I put one together, it was about two dozen lines of code.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hello MrJake,
I agree with David Crow that using TCP/IP APIs would be far more superior to the technique that you are presently using.
However, to achieve your approach, I suggest declaring a string variable and then use it to build up your command line (for the system() function). I would also suggest redirecting the output of "ping.exe" to some external file that you can open up and read in order to process and analyse the output of ping.exe.
The following is an example :
char command_line[100];
sprintf (command_line, "ping -c 2 %s > ping.txt", ip);
system(command_line);
...
...
...
Give it a try.
Regards,
Bio.
|
|
|
|
|
hi
one more favour plz....... how do v change grid lines color in list conrol
thnks
Muhammad Azam
|
|
|
|
|
hi
i want to change the row height of a list control (report style). can any one help me, how to change row height of report sytle list control.
i have searched a lot for this on internet but no one has posted any such article.
thanks in anticipation
Muhammad Azam
|
|
|
|
|
Reposted here from Operating Systems / SysAdmin. I apologise if this is impolite but it seems more likely to get answered here.
I need a simple, programmatic way to set up a small number of accounts on new PCs running Windows XP.
I'm prepared to write script (VBScript or Javascript), .NET code (C#) or even an app in C++
Please can someone give me a clue as to where would be the best place to start. Just pointing me to something relevant on MSDN would be fine.
Thanks in advance,
Phil
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
OK, try MSDN here NetUserAdd[^]
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Excellent! Thanks, I'm off and running.
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
OK, so I can add a user but NetGroupAddUser fails with NERR_GroupNotFound.
NetQueryDisplayInformation will only display one group called "None"/"Ordinary users".
The program is running as a local administrator and I've even tried impersonating Administrator.
Any ideas?
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
Is the XP system connected to a Domain with Active Directory ?
How about NetLocalGroupAddMembers() ?
|
|
|
|
|
Hello,
I'm writing a C# application using managed and unmanged c++ libraries.
I have a bug, which causes an assertion "_BLOCK_TYPE_IS_VALID".
The message appears always in a different places.
Exceptions handling is not helping. Where to look?
|
|
|
|
|
Hi there!
I'm trying to show a series of bitmaps in a DialogBox but when I do this i have a big memory leak and I don't find how to stop it...
I've found that every time i call SetBitmapBits a new bitmap is allocated somewhere.
Oh, I'm also trying to deal with the flickering of the image
code:
void CLeakTestDlg::OnBnClickedLoop()
{
CClientDC dcScreen(this);
BYTE *bmp = new BYTE[250*250*4];
int i;
CBitmap image;
image.CreateCompatibleBitmap(&dcScreen,250,250);
for (i=0;i++<100;)
{
memset(bmp,(int)(2.5*i),250*250*4);
image.SetBitmapBits(250*250*4,bmp);
cImage.SetBitmap(image); //cImage is a CStatic control of a Picture Control
}
delete[] bmp;
}
|
|
|
|
|
eNez wrote:
...i have a big memory leak and I don't find how to stop it...
How do you know there is a memory leak?
I do not see that the for loop is doing anything productive. The first time through, it sets bmp to value 0, then to 2, then to 4, etc. Since little to no time has elapsed between calls to SetBitmap() , the net result is that only the last call to SetBitmap() will be seen, and even then I'm not sure what it will be.
Have you checked the return value of CreateCompatibleBitmap() and SetBitmapBits() ?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
After an run the function Task Manager show me 25 more Mb used by the program
i'm using vs.net 2002,
apparently the same code compiled under vc++6 have any problem.
(also vs.net 2003 have the same leak)
this loop do anything
the true program have to load images from a raw file and show them in sequence in the dialog.
because the image are encoded in a non-standard way i have to put the pixel values one by one in the bmp matrix.
I've written this function after seeing the leak in the main program(1000 frames = ~ 130Mb lost).
this are the same commands used to display the pictures and the memory is flooded the same way...
this is the code of the project
http://ombre.gamersrevolt.it/leaktest.zip
|
|
|
|
|
eNez wrote:
After an run the function Task Manager show me 25 more Mb used by the program
Do not use Task Manager to determine your program's memory consumption. It's a common misconception that the numbers reported by Task Manager are an accurate representation of your program's memory consumption, when they are actually just the size of your program's address space. Read this article, especially the last section, for a more detailed explanation.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
i see...
but this thing has anyway something wrong...
if i keep pushing the button that lauches the loop the memory used keep growing.
and... using GDIndicator (http://msdn.microsoft.com/msdnmag/issues/03/01/GDILeaks/default.aspx)
i see 100 more bitmaps every time i run the function...
and last thing the SAME code compiled with vc++6 don't eat memory, and don't uses more bitmaps
(and it run also considerably fast)
at least all this is strange
|
|
|
|
|
Need to close from handler of opening.
ShowDropDown(false)
not helps, due to it is probable handler ?
How to resolve this?
Thanks
|
|
|
|
|
Use the CB_SHOWDROPDOWN message
SendMessage(m_combobox.m_hWnd, CB_SHOWDROPDOWN, 1)
SendMessage(m_combobox.m_hWnd, CB_SHOWDROPDOWN, 0)
Ivan Cachicatari
www.latindevelopers.com
|
|
|
|
|
Very simple question how do you invert (or NOT) the bits in say a char .
e.g. char x = 0xCF;
<br />
Invert(x); From what I can see ther are only AND, OR and XOR that work on bitfields.
I am sure I am missing something!
Not too rude please.
|
|
|
|
|
use the ~ bitwise operator.
<br />
char x = 0xCF;<br />
char NOTx = ~(x);<br />
I Dream of Absolute Zero
|
|
|
|
|
Thanks, could not find it in my reference book or help.
|
|
|
|
|
http://www.codeproject.com/cpp/bitbashing.asp[^]
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
if you want to reverse them you can use the Binary XOR (^) by 0xFF //(255)
example:
0xCF ^ 0xFF = 0x30
0x30 ^ 0xFF = 0xCF
|
|
|
|
|
Hello
I am developing an application with DLL support. I selected an MFC shared DLL accordingly and everything goes on fine, when I run the application from the Execute tool bar in the Visual Studio. But when I run the application independantly, by double clicking the executable in the Debug folder, I cannot load the DLL. Help me with a solution to this.
Regards,
Sreekanth Muralidharan,
Hyderabad
|
|
|
|
|
Check the working directory within VS. The DLLs must be in there.
Generally when an application looks for its DLLs it start by looking in:
* The working directory.
* The windows directory.
* The windows system directory.
You can either create a shortcut so that the working directory is the same. Build the application into the appropriate working directory or move/copy the DLLs the applictaion needs into its working (DEBUG) directory.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|