C++ :: Copy Anything On Already Written Console / Command Prompt?
Oct 22, 2013
i want to know how to copy data from already written text on console?
i am actually making a program that reads texts already printed over console so i want to capture that data again but i must not have a copy version of every thing behind the scenes i.e. in the background. I need to know how to capture data or amount of some data from console output? for example:
[console started]
It's imaginative console for the purpose of understanding.
I will make a very impressive program which will wow! you and to my instructor.
|
[/console ended]
Now i have no copy of any data printed on console/command prompt or whatever you say it. My question is how can i copy following strings from console?
1) It's imaginative console for the purpose of understanding.
2) It's imaginative console for the purpose of understanding.
I will make a very impressive program which will wow! you and to my instructor.
3) very impressive program
4) understanding.
I will make
NOTE: Small bold '|' is my most recent cursor position on cmd.
Moreover in case you need about my IDE,
i am using :
Windows 7 Ultimate Service Pack 1.
Microsoft Visual Studio 2013 Ultimate.
Architecture 64bit.
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 am facing a problem in C++,I want to execute a command in Command prompt from a specific path.I am able o select a path and execute cmd.exe using the function ShellExecute but the problem is after selecting the path I am not able to execute the command, the command is appearing on another command prompt.
I am looking to make a program for C++ that has a GUI other than command prompt. The program I am trying to create will ask certain questions and display the results at the end after all questions are asked and have 2 copies of the results one over the other that can be printed as a receipt. Basically I am wondering can I do this using C++. Also I want another GUI other than command prompt as well. Something close to what windows uses if possible.
Im writing program for a rail fence cipher that should run from the command prompt and take in two .txt files, one containing the key for how many rails there should be (between 1 and 25) and the other containing the message to be encrypted. Both of those txt files should be entered from the command prompt, taken in with the program's arguments, not asking the user for input I think I have the logistics of how to get the program to encrypt it worked out, but every time I try to run the program it keeps on crashing.
The program should run when I enter this:./railcipher samplekey.txt samplemessage.txt
I'm pretty sure my issue lies within my first few lines of code, with the main(), or with the FILE*, but I dont know what I would need to change it to for it to work properly.
Code: #include<stdio.h> #include<string.h> #include <stdlib.h> int main(int argc, char **argv[])
If I compile code which uses cin using the command prompt, then run the compiled program a new window opens when it reaches the cin line of code, for the input. If there is no cin used then all printing happens in the original window. Is there a way to stop this behavior of the opening of a new window?
I am having a problem with my c++ code. I am attempting to clear the text off of the command prompt screen in a text based game program. I put a restart option using a goto in my program. How would I be able to clear all previously displayed text.
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.
Code: cout << "Put in the names of people, press q to exit" << ' '; while((cin >> people_inp) && (people_inp != "q")){ Person *p = newPerson(people_inp);
[Code] ....
The problem of this code is when you put in the names(via cin) and press enter command prompt will disappear. What should I do so that Command prompt will not disappear after I input some names? I mean it disappears without you pressing a key.
How can I send information and receive from external command prompt from my program??. I want to run an external command prompt, a code that's is not mine, to send information to this command prompt, then make my program hit enter at the command prompt and then receive back information from the command prompt.
I am making an application that processes multiple files (typically > 500) through a command prompt call. The way I start the command prompt app is by looping using a call to CreateProcess for each file that is to be processed. It works fine, except that I somehow loose 'connection' to my app so that
1: Windows says that the app. is 'Not Responding' 2: The Cprogress bar in my app is not updated before all files have been processed, even though there is a CreateProcess call and a Cprogress.StepIt() from the app for each file that needs processing.
I somehow suspect that the CPU gets swamped... I do not want that Windows starts to say that my app is 'not responding' and I want my Cprogress dialog bar to update according to the number of files that are progressed through.
I wonder if multithreading is the OK way to go instead of just kicking of series of CreateProcess calls? Maybe my CreateProcess is not ending correctly? It seems as if my app is 'not regaining control' before very late. The app never crashes though.
My CreateProcess code is listed below, maybe there can be a problem with it, or maybe I should do things in a different way? My app basicaly works as it never crashes, but with above mentioned problems it is NOT a pro solution...
void CMultiFilerDlg::ProcessFile(CString pdfFile) { int i=0; DWORD ProcID; // Open file in text mode: STARTUPINFO si; PROCESS_INFORMATION pi; char cmdArgs[2052];
I used the Console's CursorLeft and CursorTop properties to specify the exact areas of the screen where I wanted to print information. I ended up with a 'table' full of data.
Then I used the System.Diagnostics.Trace class and added a TextWriterTraceListener and a ConsoleTraceListener object to its Listeners collection.
Then I replaced all the instances of Console.Write with Trace.Write.
The data displayed as expected on the console. But on the text file the info was printed in the same order the info was outputted to the Console. ie: all the characters used to separate rows lumped together, followed by all the characters used to separate columns lumped together, followed by the actual data that was printed between those characters, all lumped together.
I can see why I ended up with this mess. The TextWriter is oblivious of the fact that the Console's cursor position was arbitrarily modified by the application code before and after each character and piece of data was printed to the Console.
Is there a way I can just grab the text that was printed to the console, ignoring the actual order in which the individual characters were printed, and save it as a string or directly print it to a file exactly as-it-is?
I have had experience in programming from python (slightly related, html/css) and the computercraft from minecraff (basic i think it is).
My question is mainly about the C and past experience with the computercraft.
1. Is it possible to split the command console into 2 parts (a visual area and a text area) 2. Is it possible to use any form of pixel art or custom characters within any command console using C.
I'm taking an operating systems class and I'm trying to write a script that would execute a program in Simple OS.I"m not sure if this is the right place for this because although the entire OS is written in C, "asm" are assembly language code. Anyway when I run the OS in virutal box and try to run a program, I get a "Fatal Execption" in a loop until the entire OS crashes. So then I try to debug my code BUT when I add printf statements and try to run the code again I don't get to the "fatal execption" and the entire OS just crashes. 1) why can't I add print lines? 2) what's going on with the fatal execption?
//////////////////////////////////////////////////////// // Loads program and executes it in user mode // #include "kernel_only.h"
Here is a working C++ program and its output that reads the names of a certain number of functions whose names are written in a disk file that provides the control parameters in a near-real time fashion. Based on this information, the program calls those functions whose names were given in this text file as parameters. The method I have used is to build a map of functions that connects the names of the functions to the actual functions. Once this map is created, then it is very easy to iterate in such a way that only those selected functions are called.
So far this is working well, and it makes the logic of the code easier because ultimately there will be a large inventory of functions (probably hundreds of functions), and this way of pre-building a map of functions avoids writing hundreds of if statements in the code. Of course, pre-building this reusable map in the background is still equivalent to writing that many if statements, but at least it makes the code very compact and much more automatic, since it is done only once.
But I now have a related question: In this case (when the selected subset of functions to call is given as incoming data as in this example), does C++ make it possible to avoid using maps of functions, by directly applying the string variable that holds the name of the function in order to call the original function immediately For instance, if a string variable s = "MyFunction", then is there a more direct way of using this string as if it were the actual function whose name is spelled exactly in that way? This would make the code even more compact.
Here is the sample test code for the map of functions, and its output:
First of all here is the text file "FileForNamesOfFunctions.TXT" that contains the part of the "data", which is the set of functions select from from the inventory and only call these:
Code: function2 function3 function5 And here is the C++ code that uses this "data":
i cant display the data written to this file in a switch statement (case 2) what am i doing wrong..the file data is being written into the text file but i cant display it
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?