C :: Adding A Command To Program

Dec 2, 2013

I'd like to add a 'command' to my C program. For example if someone types 'get out' it closes the shell and quits. I want the 'get out' command to work like 'exit'. How do I write a code like this

Code:
char entry[15];
scanf("%[^
]", &entry);
if (entry = "get out")
do "exit";

View 14 Replies


ADVERTISEMENT

C :: Program Stalled At System Command?

Dec 22, 2014

I am trying to recreate this bash command in c code:

Code: bash-4.2$ exec 3<<<teststring
bash-4.2$ cat <&3
teststring
bash-4.2$

I've written a small program to do this as shown below:

Code: bash-4.2$ cat test.c
#include <stdio.h>
#include <string.h>
#include <fcntl.h>

[Code].....

View 3 Replies View Related

C++ :: Program That Executes A Command Between Computers

Jul 28, 2014

I'm currently making something with C++ for a computer at my house. I have a program in which I let run minimized and hidden on my home computer which will save any application that is opened. It will log it so I know if my kids are on my office computer (they shouldn't be.).

I'm curious as to if I can make the program linked to a program I make on my work computer (at my workplace) and execute a command. I'm interested in making it so I can always be connected from the Workplace app to the Home Office App.

My idea for the program is to have a sort of administrative way of shutting the computer down or locking it remotely. If I see they are using the PC in my office, I want to be able to simply type a phrase and shut the computer off or lock them out.

View 1 Replies View Related

C++ :: Make Program That Has GUI Other Than Command Prompt?

Nov 22, 2013

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.

View 5 Replies View Related

C/C++ :: System Call A Command From Within A Program?

Sep 17, 2014

how to invoke a UNIX command within a program

I found this:

dd if=/dev/urandom of=myrandom bs=100 count=1

and I found this:

dd if=/dev/zero of=mytestfile.out bs=1 count=0 seek=1G

I want to call this command, by using the command line and typing Generate or something to that effect.

Basically, I want to be able to build random size files, content isn't important to me at this time.

View 8 Replies View Related

C++ :: Execute Command In Command Prompt From Specific Path

Feb 15, 2013

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.

View 4 Replies View Related

C :: Incorporate Command Line Arguments Into Program?

May 26, 2014

In the following program, I have gotten it to work with IO redirection (not shown in this particular code), and have made some minor adjustments to get it to work with file processing. The only thing I have to do now is get it to work with command line arguments, and am slightly lost (and I have looked into it).

I basically just need to take a text file from a certain directory and send it to my program. Would need two files, an input and output file.

main.c
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "LAB_6B_7B.h"

[Code].....

View 8 Replies View Related

C/C++ :: Program That Can Merge Files From Command Line In Li

Sep 22, 2014

I have written a C++ program that is supposed to open two text files (prog2a.dat and prog2b.dat) and write the contents of a specified range of lines to an output file (outfile.dat). I wrote a program that based on the example we were given (to take lines 5-15 from the first file and lines 4-12 of the second file and merge them into the output file) works perfectly. However, after asking my professor for some clarification on another part of the assignment, I found out I have not done this correctly. I have the code written so that it will always output the range of lines I mentioned earlier, but the program is actually supposed to allow the user to merge the files from the command line using whatever range they want by typing in the following command:

prog2 in1 5-15 in2 4-12 outfile

But I'm not sure how to tweak my current program to allow this to be done.

Here is the code that I have written, keep in mind that this works properly for the way it is written, but not how it is supposed to work for the purposes of the command line (hopefully that makes sense):

#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
int main() {
// Create output file
std::ofstream outFile("outfile.dat", ios::out);

[Code] .....

Is there any simple way to make this work as I described using the command line? Also, I am supposed to break this up into three files, a header file, the program file, and a test file (the test file contains main() and should close the 3 open files and display any error messages), but I'm getting really confused as to what should go in the header file. I know the header file should contain class definitions and constructors, but don't really know how to make that work for this specific program?

View 13 Replies View Related

C/C++ :: How To Execute Program Through Command Line With Arguments

Aug 13, 2012

i wrote the c program for command line arguments,but i don't know how execute c program through command prompt

i did like this

d: cin>

then how should i proceed for execution

View 1 Replies View Related

C :: How To Test Program That Opens Files In Command Line

Mar 10, 2014

The below program is supposed to display the contents of all files listed in the command line. When I try to run the program I get the fatal error "Debug Assertion Failed" Expression: file != NULL. I've done some researching on the matter and I gather it might be because I don't have any files listed in the command line?

How to enter files in the command line! I opened the Command Window in Windows XP and tried typing in "C> argc" and "% argc" (argc being the name of the file containing the below program) without any luck.

Code:

#include <stdio.h>
#include <stdlib.h>
int main (int argc, char * argv[]) {
int ch; // int to hold EOF
int count;
FILE *fp;
for(count = 1; count <= argc; count++) // agrc loop

[Code]...

View 5 Replies View Related

Visual C++ :: Command Prompt - Running GUI Program In Background?

May 2, 2013

No I definitely used Visual Studio Command Prompt

c:Program FilesMicrosoft Visual Studio 9.0VC
un_process_from_service>make.bat

View 7 Replies View Related

C :: Gzip System Linux - Program To Unite 2 Commands Into 1 Command

Sep 15, 2013

I'm writing a program to turn the two commands "gunzip file.tar.gz" then "tar -xvf file.tar" into "x file.tar.gz", but I've ran into a problem I can't find a solution to, here are the outputs I get depending on if I use a gunzip -f flag in my system() call or not:

if I use: (void)system("gunzip ", store );
> x file.tar.gz
gzip: compressed data not read from a terminal. Use -f to force decompression.
type: gzip -h
store 1: file.tar.gz
tar: option requires an argument -- 'f'

[code]....

I don't know if the problem is something to do with my code or something to do with gunzip and if it is to do with gunzip if I can even solve it with my code? I've tried for a while to find more info and read the gunzip man file, ran "gunzip file.tar.gz" outside of my program and found that it works normally producing file.tar so I suspect the problem is related to system()?

View 3 Replies View Related

C :: Send Information And Receive From External Command Prompt From Program?

Jan 10, 2014

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.

View 5 Replies View Related

C++ :: Program To Search Index File Using Command Line In Linux

Oct 28, 2014

I have code that creates an index file created from a data file of records.

#include <iostream>
#include <fstream>
#include <map>
#include <sstream>
#include <string>
#include <iomanip>
using namespace std;
class Record {

[Code]...

I now need to write a second program that allows the user to enter a command on the Linux command line such as

search 12382 prog5.idx

and returns the information for the record with that key. The code I included for the index file is correct and works properly, but how to write the second program.

Here is the index file created by the first program:

8: blank 0 $ 0.00
12165: Item16 30 $ 7.69
12345: Item06 45 $ 14.20
12382: Item09 62 $ 41.37
12434: Item04 21 $ 17.30
16541: Item12 21 $ 9.99
21212: Itme31 19 $ 8.35
34186: Item25 18 $ 17.75
41742: Item14 55 $ 12.36

The top line is a dummy record, the first number is the size of the file.

View 19 Replies View Related

C/C++ :: Unable To Create A Program That Takes Command Line Arguments And Prints Last One

Jan 18, 2015

I'm just getting back into the swing of things after a long time of not programming. I'm trying to create a program which takes in command line arguments and prints the last one. My code is as follows:

#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
string x;
vector<string> arguments;

[Code]...

And the error message I receive, a simple but frustrating one, is as follows:

Enter arguments, enter STOP to stop: Segmentation fault...

View 1 Replies View Related

C++ :: Program Not Adding Up Totals

Mar 5, 2014

'm new to programing and I'm trying to get this program to add up a price of coffee to the add on extras such as cinnamon, etc. But once the program runs it doesn't add up the coffee price with the extras and I've been at it for hours...

Code:

#include <iostream>
#include <cstdlib>
using namespace std;
int main()

[Code] ......

View 6 Replies View Related

C# :: Program Keeps Adding 1 To Result?

Oct 21, 2014

I am creating a program that allows the user to enter the number of days worked and calculates the amount of money gained by doubling the amount from the previous day, starting with .01 cents. The program works fine except for in day 3, the program adds .01 along with doubling the amount from day 2. Also I must use a List Box.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;

[code]....

View 3 Replies View Related

C# :: Adding Program Into Context Menu

Feb 29, 2012

To add my program into the context menu (when the user right click on excel file). I used the following code:

Code:
public static bool AddContextMenuItem(string Extension, string MenuName, string MenuDescription, string MenuCommand)
{
bool ret = false;
RegistryKey rkey = Registry.ClassesRoot.OpenSubKey(Extension);

if (rkey != null)
{
string extstring = rkey.GetValue("").ToString();

[Code] .....

I used the following function to retrieve the excel file path has been rightclick choose to load the program:

Code:
public static void OpenExcelFileWithEasyForm(string filePath)
{
try
{
string excelFilePath = Path.Combine(Path.GetDirectoryName(filePath), string.Format("{0} (EasyForm){1}", Path.GetFileNameWithoutExtension(filePath), Path.GetExtension(filePath)));

[Code] .....

But I still do not load the excel file into my program by selecting the program from ContextMenu (right click on excel file and choose program). Although if select the path to excel file from the program, the data from excel file is loaded into the program.

I'm still missing something at function OpenExcelFileWithEasyForm(). How to complete this function to load the excel file into my program when selecting programs in ContextMenu.

View 1 Replies View Related

C :: Adding Countdown Timer To Program

Dec 14, 2013

I want to add a countdown timer to my program so after specific time it go back to the main menu my program is something like vending machine....

View 1 Replies View Related

C# :: How To Get Program To Keep On Adding Rows To Datagrid

Jul 6, 2014

I want to be able to keep on adding a row to my datagrid every time i click a button, the row will hold the text of the text box and the combobox in its individual cells, is there a way to do this without inserting a ridiculous amount of code?

Attached image(s)

View 1 Replies View Related

C/C++ :: Program For Adding Many Fractions With Sum Notation

Jul 16, 2014

I was trying 2 write a program that would calculate the sum notation of 1/(i^2) with the starting number to be 1 and goes up to the nth term. For instance if the user inputed 3 then the sum would look like 1+1/4+1/9. I somehow made a code but it gets weird numbers which some include negative numbers... when I input a number that is above 5.

#include <stdio.h>
#include <math.h>
int main(int argc, const char * argv[]) {
int n;
register int i=1;
float b;//For part 1

[Code] ....

For some reason I can't edit printf("%f",/>/>; when I post it as the topic so ignore that part cuz Ik its supposed to be written as printf("%f",/>;

View 6 Replies View Related

C++ :: Adding Vowel Counter To Recursive Program

Nov 12, 2013

adding a vowel counter to my recursive program which i completed.

#include < iostream>
#include <cstring>
using namespace std;
void reverseDigits(char num[], char revNum[], int,int);
int main() {
char letters[10] = {' '};

[Code]...

View 4 Replies View Related

C++ :: Star Pyramid Program - Adding Stars?

Sep 13, 2013

I have written a star pyramid program, it adds two stars at a time but I want to rewrite the program so the stars double each time.

#include<iostream>
using namespace std;
int main() {
int a = 0, b = 8;
for (int c = 1; c < 10; c++) {
for (int space = b; space > 0; space--)

[Code] ...

View 1 Replies View Related

C++ :: Adding Search And Delete Function To Program

Jun 21, 2013

I'm trying to add a search and delete function to my program

#include <Windows.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <iostream>
using namespace std;
class Cvampire{

[Code] ....

View 4 Replies View Related

C++ :: Adding Employee Names In Function Arranged Program

May 13, 2014

The program that I have written below is working. It calculates a number of payroll type variables and most recently the net pay average (All this is working 100%).

My problem is that I need to add first and last employee names to the program but every time I do this I end up ruining the working program. I've successfully added first and last names to similar programs in the past(ones that make use of an array and while loop) but never to a program that uses functions (I always have problems doing this).

My question is what codes do I use to add a first and last name variable and where do I put those codes within my program so it runs/displays correctly.

I think the coding must be similar to what I've used in the past charr and of course firstname[i] and lastname[i] lines.

Current Input File:
16454025.00
89324020.00
71044012.50
28164026.00
53874021.00
67804013.50
56414011.25

90006025.00
90015020.00
90025523.00

Ideal input file (would include names) Example.
1645 Bob Smith 40 25.00

Syntax:

#include <iostream>
#include <iomanip>
#include<fstream>
using namespace std;
//function prototypes
int readalldata(long int[], int[], float[], const int);
void findovertimehours(int[], int[], int);

[Code] .....

View 8 Replies View Related

C++ :: Program That Needs Auto Start At Windows Startup - Adding Registry Entries?

Jan 18, 2012

I am developing a program that needs auto start at windows startup. For that I need to add Registry entries. Also the program needs to read some registry keys. What are the functions i need to do these.. Simply I need to

check if the startup key already exists
add a new key if it doesn't exist
read a key values

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved