I have a question about to run an MFC dialog based C++ application from console: if I run my application from console, I see the application start and the console immediately back to prompt. I need that console wait the application exit before show me the prompt again. I tried on Visual Studio 6, 2005 and 2010 but the behavior is the same.
The program does compile the average and the mean correctly. I can't understand why the standard_deviation member function isn't applying the sqrt properly:
#include <iostream> #include <iomanip> #include <cmath> using namespace std; const int N = 10; class Standard_Deviation {
my C++ console application should be like a command prompt. There are "command lines" to execute in the command prompt.Here are my main prompts for spotlight:
Encode - New data entry View - Read data from text file Search - Find record from text file Update - Save changes per text line from the existing text file Delete - Delete lines from the text file
Now, I manage to do the tasks for Encode, View, and Search..But unfortunately, not in Update..I've been working this for a week already..
#include "stdafx.h" #include "iostream" #include "string" #include "fstream" using namespace std; //to omit the std }
I'm thinking of making a horror text-based game, which would use sounds, if you could also tell me of an API to display images in an alternate window that would be nice.
I have an HTTP/1.0 webserver that I'm building in C that needs to exhibit CGI script functionality. Specifically, what I'm having trouble with is that I have two processes: process 1 is the webserver, process 2 is the CGI script. I fork in the webserver, and then call exec to run the CGI script (specifically, I used execv()). I've read from the CGI specifications in the RFC that in the case of a webserver receiving a POST request, the CGI script should read the arguments for the POST request from stdin. However, when I write to stdin, it simply echoes what was written to the terminal window and when the CGI script tries to read from stdin, it blocks.
So, with all that said, I'm pretty sure there is some simple conceptual explanation to my problem, but I can't figure it out. Do I need to use pipes or some form of interprocess communication to send the data from the webserver to the CGI script, or can it just be done with stdin (and possible stdout)?
I am stuck in visual studio 2010 file I/O ... i placed file1 file2 using the following program under VS2010/projects/projectname/file, file1 and also in debug also once......I am actually using cmd line arguments in debug mode
Code: // feof files.cpp : Defines the entry point for the console application. //
#include "stdafx.h" #include<stdio.h> #include<stdlib.h> #include<conio.h> int main(int argc, char* argv[])
[Code] ....
I dont think in C++ forum the printf will do any problem...when i run the program it says "cannot open source file" and a window appears saying"Debug assertion failed"....and other details such as Expressionstream!=NULL).perror
I want to take the standard output of a shell command (in Red Hat, using tcsh, in my case) and redirect it into my program for processing.
(Then ideally I would love to take the output of my program and redirect it to yet another command, but this is a second issue.) Simple example: I naively thought this might work:
I want to type this on the shell:
Code: $ echo Harry > hello and I was expecting this output on my terminal: Code: $ hello, Harry And this would be my simple hello program: Code: #include <iostream> #include <string> int main() { std::string usrInput; std::cin >> usrInput; std::cout << "hello, " << usrInput << std::endl; return 0; }
I'm building a simple system management console application. I've abstracted the console "Menu" and derived from it a "WelcomeMenu" class with public inheritance.
The problem is that when instantiating a Menu* object and assigning it a new WelcomeMenu...I'm still not able to use WelcomeMenu's "ShowWelcomeMessage() with the Menu* object. Instead, I get "error: Class 'Menu' has no member function call 'ShowWelcomeMessage().' Which is true, but I thought a pointer-to-Menu object should be able to use the public methods of derived classes without casting in this case. Code follows.
// Menu and WelcomeMenu Classes #ifndef MENU_H #define MENU_H
I want to open one new CMD from console application, write text into the new CMD and then coming back to the control on the old cmd. (like interactively working on the both)
look into the below code
Process P1 = Process.Start(@"C:WINDOWSsystem32cmd.exe"); P1.StartInfo.RedirectStandardInput = true; P1.StartInfo.RedirectStandardOutput = true; P1.StartInfo.UseShellExecute = false; StreamWriter wr = P1.StandardInput; wr.WriteLine("First line in New Cmd"); Console.WriteLine("First line in Old Cmd"); wr.WriteLine("Second line in New Cmd"); Console.WriteLine("Second line in Old Cmd");
it is giving the exception "StandardIn has not been redirected"
I'm trying to write a program that passes Windows messages back and forth from another program that controls a laboratory instrument. I was able to write a program that successfully passes instructions, as evidenced by the instrument doing what I tell it. However, I am having trouble getting a return status from the instrument. The manual instructs the following:
// demo code, etc. // send message to the instrument operating software here... SendMessage(hwnd, WM_COPYDATA, tag, (LPARAM) &cd)
Either a completion message or return data is returned. Remote commands ReturnStatus, ReturnTiming, and ReturnData return data. In either case, data is received through an asynchronous windows message inside Win32 COPYDATASTRUCT type data packet.For example, a typical OnCopyData window callback is shown below, where the string data retrieved is finally stored into a Microsoft CString object. Note the use of variable replyTag, discussed above, which is used to isolate the correct windows message returned.
BOOL CUserDlg::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* cd) { …. if (cd->dwData == replyTag) { /* String pointing to status */ CString retStatus = (char*) cd->lpData; } …. }
I can't tell if my problem is in generating the replyTag, getting the HWND to my own console window, or the actual receiving part of the code.
When setting the replyTag, the manual instructs: UINT replyTag = RegisterWindowMessage(“SOFTMaxProReplyMsg”);. However, I have to put an "L" in front of the string or I get a data type error (can't convert const char* to LPCWSTR).
When setting a HWND for myself, the manual instructs: HWND MyWnd = GetSafeHwnd().
That produces an error because GetSafeHwnd is a function of the Cwnd class, and I don't have a Cwnd. I have replaced it with HWND MyWnd = GetConsoleWindow();
When listening for the reply message, the manual instructs what I quoted above. However, I again don't have a Cwnd. I therefore simply used
The above if statement always evaluates false, and the cd.lpdata contains the message that I had sent out instead of a reply message. How to get a reply using my console application. Here is the full code of my function:
Code: #include "stdafx.h" #include<iostream> #include<vector> #include<string> #include<afxwin.h> using namespace std; void SendCommand(string command) { // Get tags to identify the receiving and sending messages
I am using Windows 7 32bit OS and want to detect the CPU power button press event in my console application developing in C language.
I configured the power button setting to "Do Nothing" which is in "Choose what the power button does" options in Control Panel->Hardware and Sound->Power Options. So now i want to detect this power button press event and do some processing in my application then i will initate shut down from application itself. Looking for windows API details which will detect the power button press event.
I have been struggling to read a certificate in windows store from C++ DLL, but its not happening. from console application I can but when same code built as a DLL and tried to access from a separate console application. I think its not going to windows store to read the cert.
i have to create a console based application in c language that can join and split bitmap images. the requirements of the application are as follows :
1. Split Image Enter number of parts: Enter source image path: Enter destination folder: 2. Join Images (all images should be of same width and height) Enter image path: Join more Image (y/n): 3. Exit
Take care of following things:
- Application should show number of images processed while running. - Acceptable Image format is BMP only. - Application should give all the validations for correct image name, type, size, path, etc.
I'm making a flash card type console application using visual studios 2013. The flash cards contain character that I can display using unicode. So far I am looking at about 200 characters across 2 unicode blocks which I don't want to hard code into my arrays. I thought of initializing my arrays using a loop. The only problem is I don't know how to add in hexadecimal. So is there a way to initialize my array without having to input 200 values my self? Also is hexadecimal addition possible without me having to write a function for it?
I have 18,000 lines of code that i would like to upgrade to include a log file. I want to replace the cout with a stream or something similar so that i can easily output to the console and to a log file at the same time with minimal change to 18,000 lines of code. I'm nearly there.
I used this post heavily as a reference; [URL] .... however it is highly incomplete and this is above my knowledge so I'm struggling somewhat.
I was able to get the bulk of it working with some guess work and modification to the code from that link.
For some reason i had to comment out "mstream(void);" and "~mstream(void);"
to work for endl as per the previous link. Not sure if i'm even putting it in the right place. Otherwise the code works fine for streaming to both locations and such. See the code below;
#include <iostream> #include <fstream> #include <string> using namespace std; class mstream {
I'm trying to write something that when a user is at the command line, the user can type and it displays of list of commands the user can use to run the application.