C++ :: CMD From Execute Closing Instantly
Aug 13, 2014I compiled/built a code I had and made an executed file but when i click on it the CMD closes instantly. Is there anyway to keep this open?
View 10 RepliesI compiled/built a code I had and made an executed file but when i click on it the CMD closes instantly. Is there anyway to keep this open?
View 10 RepliesIs it possible in C to instantly react to keystrokes made in console?For example, consider the following code:
Code:
#include<stdio.h>
int main(int argc, char *argv[]) {
char ch;
printf("Enter a sentence...
");
[code]....
The evaluation of the if statement inside the loop will not occur until the Enter key is pressed on keyboard.To my best understanding, It just pushes the keystrokes to some buffer, and when the '' is introduced, it evalutes the characters one by one.Is there an elegant way to instantly react to keystrokes in C?
I am trying to switch between 2 states, and the event that determines which state i am in is based on the key i've pressed. So in this case i want the webcam to start automatically, and when key is pressed it then turns it off. The way I've done it is like this :
bool webcam_on() {
int c = 0;
VideoCapture cap(0);
if ( !cap.isOpened() ) // if not success, exit program
[Code] .....
The problem with this method is that cin.get() blocks the video stream.. I wanted something that the webcam turned on until i press some key, which would trigger the release.. How can this be done?
I tried.
cin.get();
and
return 0;
is there a better way to keep the user info displaying without closing the console window.
The following not only closes the MDI children, but also the form I set to be an MDI container.
private void close()
{
Form[] childArray = this.MdiChildren;
foreach (Form childForm in childArray)
{
childForm.Hide();
}
}
... and not with a brace followed by a semicolon like in class-definitions - reason for that?
View 2 Replies View RelatedI'm using windows forms and I have a parent dialog box that consists of a text box and a drop-down that launches a child dialog box. The child takes user input and then prints dialog to the text box in the parent. However, the output does not appear in the text box until I close the child.
Now my question is, how do I get the text to appear without closing the child? I hit a button to send the info to the text box, but it still doesn't appear until the child closes. I also need to set up a button to suspend the child so that the user can click/copy/etc the parent.
I have created a MFC dialog based application. Now I want to implement such a functionailty that I will be closing my application through command prompt. And while closing of my application the ExitInstance() method of my application should get called. What is the command which I should put in the command prompt to close my application in such a way.
View 8 Replies View RelatedI created a C program that extracts some information from computer and displays it on screen. It is completed today and is going to be applied to startup programs of domain machines. It runs at logon and takes somewhat 5-10 seconds to finish execution. The output is shown on console screen & user can either close the window by clicking on 'x' or pressing 'Ctrl+c' during execution. How do i prevent both of these events?
Basically the most time consuming processes are
Code: popen("systeminfo","r");
popen("wmic qfe get installedon","r");
1st command is getting OS name,version and hotfixes installed.
2nd command gives me the date of updates installed.
I then filter out data & print required information only.
I've found that with streamwriter(sw) the data isn't displayed with the written to document until you either leave scope or use sw.close I'd prefer to keep sw open as I will be writing to the file in and out, sometimes very frequently, but would also prefer the data to be viewed in real time. Is there an efficient way of going about this?
View 12 Replies View RelatedRight after I close FIFO on the producer side, the app on the consumer side gets into an endless loop. select() returns that FIFO is ready to read. Below is the excerpt from the consumer code. The FIFO is opened "blocking" on both ends.
Code:
FifoClass fifo_r = FifoClass("/tmp/FIFO_READ");
int fdr = fifo_r.OpenR();// this->fd = open(name.c_str(), O_RDONLY , 0);
for(int i=0; ;i++) {
FD_ZERO(&rset);
FD_SET(fdr, &rset);
[Code] .....
I have an C++ application which uses Microsoft Web browser ActiveX control to launch any URL within the application. The browser is embedded in C++ form and It's working fine with all the feature Microsoft has exposed through Interface(IID_IWebBrowser2).But while any url that is using session cookie has been launched, even after closing the browser the session cookies are not getting deleted. For example if user login info is stored as session cookies,the url is using the cookies and getting launched without asking for user log in info.
But if I close the browser, and again relaunch , the cookies should be deleted and the url will not find the cookies to be used for log in . That is not happening here. Although this is session cookies , it's not getting deleted and being used by embedded browser. However, if the url is launched in IE, it is behaving as expected.
So, Do I need to delete the cookies explicitly? If Yes, How to do that?
Is it possible to write a program such that it will automatically execute the function in queue base on their priority even if user programmed it randomly?
Code:
function1(){ very_important; }
function2(){ important; }
function3(){ less_important; }
int main() { // Programmed by user
function3;
function1;
function2;
//Output: Program will execute function1, 2 and lastly 3.
}
For easier debugging, I would like to execute an own (predefined) function while beeing in a breakpoint (e.g. print some variables to a file).
Does there exists such a feature?
e.g.
- run program to a breakpoint
- a) press a keyboard-function-key (which calls that predefined function)
- b) or hover with cursor over a variable (and modify somehow the routine which shows its content on the screen)?
i need to create an small windows form, with some buttons, and then those buttons will "exectute" an action on a remote webserver.
Im searching with http requestings and didn't find nothing useful for what i need.
The basic thing is that i just need to press "EXECUTE" and then c# will press one link in the Webserver. I do not need any feedback from the page. I just need that C# execute a link like localhost/startbackup.php then the actions from the startbackup.php will run.
I do not need any information regarding if the page was successful executed or not, or even if it opens one window. Nothing.
I'm wondering whether it's possible to implement MPI to execute a process in parallel from deep within a C++ solution.
I've created a solution on VS2005 that links to several static libraries, and within one of these libraries there is a set series of tasks that require execution many times - they're independent so I'd like them to execute them using MPI if possible to speed up the run time.
The pseudo-code is:
Code:
for(i = 0; i < n; i++) // n is number of times to execute process {
PerformTask(data[i]); // perform the tasks required for each iteration of process
}
So, instead of conducting the tasks within PerformTask() in series n times, I want to split the array data between multiple processes such that they can each be allocated an even proportion of data to perform the tasks on. Pretty textbook reason for wanting MPI, right?
Now, I've read up and understood the basics of MPI implementation, but all the examples I've seen are called within the main() function of the program. But I need to do all this from within a static library, is this possible?
I've made some early attempts at implementing this, but get an error indicating the process wasn't initialised: "Error encounted before initializing MPICH", which I assumed would be due to trying to make the MPI calls outside of the main() function.
I'm new to C++ and am trying to create a program to solve the problem as described in this image: [URL] .....
Here's my code. It fails to execute the main part of the problem (years, population of A & B) but works well in recognizing errors (if PopA >PopB or if growth rate of PopA<PopB)
Code:
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main() {
string city1, city2;
[Code] .....
I have a condition and I would like to instead change the condition so that it would execute the previous statements after else statement.
It seems hard to explain but I'll try my best to illustrate anyway
if (condition)
<statement1>
else
<statement2>
So I would like to change the condition so that
if (condition)
<statement2>
else
<statement1>
And the condition is
Code:
if(!lightStateAtNextLink || !bIsLightEnAtConnection && nLinkNext.IndexToAttachedNode() != pVeh->_.stAutopilot.m_dwNextNode || bIsLightEnAtConnection && nLinkNext.IndexToAttachedNode() == pVeh->_.stAutopilot.m_dwNextNode)
And I have changed that to this. Is this correct?
Code: if(lightStateAtNextLink && bIsLightEnAtConnection || nLinkNext.IndexToAttachedNode() == pVeh->_.stAutopilot.m_dwNextNode && !bIsLightEnAtConnection || nLinkNext.IndexToAttachedNode() != pVeh->_.stAutopilot.m_dwNextNode)
I'm working on a project that's got a lot of moving parts, from feedback from a position sensor to real-time video editing. The script that runs the sensor is in C++, and the API for the video editing software (vMIX) is executed with HTTP protocol. I'm hoping to use that C++ script to control the video software (as some of the editing is dependent on particular feedback from the sensor), and wanted to see how to execute a HTTP command from a C++ script.
View 3 Replies View RelatedI'm trying to create a program that will show what the 12th digit of a UPC code would be. However, once the user enters the first 11 digits the program doesn't execute the last call of printf. The program compiles with no issues.
Code:
#include<stdio.h>
int main() {
int o1, e2, o3, e4, o5, e6, o7, e8, o9, e10, o11, oddsum, evensum, twelve;
printf
[Code] .....
Im going through a C tutorial and im going to create a Database as part of the course. Im just in the very beginning of the project so its a very simple program so far.
Code:
#include<stdio.h>
main(){
/*Variabler for att lagra information om skiva*/
char title[200];
char artist[100];
int tracks;
int price;
[Code] ....
The first switch case statement takes me to the menu of choice, 1 or 2. However, chosing menu option one and trying to input a title or artist name, the program crashes.
Next, going into menu option 2 and then trying to print out, for example, title nothing happend. The process just ends.
Again, im sure this simple prototype is full of errors ....
I want to execute one command using batch file but non of below code is working. Following are codes for executing batch file, First trial:-
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
if( !CreateProcess( NULL,
"cmd /C sa.bat",
[Code]....
Non of above code is working for me but when open same batch file using double click it work like I expected.
Following is content of the file,
C:windowssystem32wusa /uninstall /kb:2718695 /quiet /forcerestart
Command use to uninstall internet explorer 10 an install internet explorer9.
System();is bad, I get that. Is there another way, that works across platforms I can use to execute an external program. If not, is there a windows specific way.
View 2 Replies View RelatedI have simple LCd_call function . I am calling this function from main . I wanted to call this function once. problem i am facing here, When lcd_call function being called. It enter the cases but instead of staying paricular case it coming back and starting case 1 iteslf . for every 6s it change the case to 1:
View 2 Replies View RelatedHow to set execute statement in the end of sql, Attach is my code:
private void InsertintoDB() {
string strSQL = "";
string strDBType = System.Configuration.ConfigurationManager.AppSettings["DBType"];
string strConn = System.Configuration.ConfigurationManager.AppSettings["DB_CONNECTION_STRING1"].ToString();
string strInsertTableName_Sql = "CIMMGR.[dbo].ANSDATA";
[Code] ....
Code:
void Arrival_MainThread::Body () {
t1 = new boost::thread((Arrive_Fctor()), 2);
t2 = new boost::thread((Arrive_Fctor()), 10000);
t3 = new boost::thread((Arrive_Fctor()), 3000);
Code:
class Arrive_Fctor {
public:
void operator()(int mean) {
m_Arrivals = new Arrivals(mean);
m_Arrivals->Activate();
#ifndef NO_RESOURCE
[code].....
The order of arrivals always appear as 3,2,1 it can't be 1,2,3 or 3,1,2 or something like that?
The body method is called when m_Arrival->Activate() is executed, and it is running as an independent thread.