1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How do i check if my program is running using command prompt

Discussion in 'Meet and Greet' started by nissignt, Dec 20, 2012.

  1. nissignt

    nissignt New Member

    Nov 9, 2010
    Likes Received:
    Trophy Points:
    Karkov Ukraine
    I copied a CPC program example from Hart windows System programming.
    It built and ran successfully how ever i have no idea how and what to write in command prompt as stated in the example.
    // CPC.cpp : Defines the entry point for the console application.
    #include "stdafx.h"
    /* cpC file1 file2: Copy file1 to file2. */
    #include <stdio.h>
    #include <errno.h>
    #define BUF_SIZE 256
    int main (int argc, char *argv [])
    FILE *inFile, *outFile;
    char rec[BUF_SIZE];
    size_t bytesIn, bytesOut;
    if (argc != 3) {
    fprintf (stderr, "Usage: cp file1 file2\n");
    return 1;
    inFile = fopen (argv[1], "rb");
    if (inFile == NULL) {
    perror (argv[1]);
    return 2;
    outFile = fopen (argv[2], "wb");
    if (outFile == NULL) {
    perror (argv[2]);
    return 3;
    /* Process the input file a record at a time. */
    while ((bytesIn = fread (rec, 1, BUF_SIZE, inFile)) > 0) {
    bytesOut = fwrite (rec, 1, bytesIn, outFile);
    if (bytesOut != bytesIn) {
    perror ("Fatal write error.");
    fclose(inFile); fclose(outFile);
    return 4;
    fclose (inFile);
    fclose (outFile);
    return 0;

    Microsoft Windows [Version 6.2.9200]
    (c) 2012 Microsoft Corporation. All rights reserved.

    c:\Users\mcfoxxy\Documents\Visual Studio 2010\Projects\CPC\Debug>
    Please Help
  2. hobbyist

    hobbyist New Member

    Jan 7, 2012
    Likes Received:
    Trophy Points:
    on the command line, you'd enter something

    c:\Users\mcfoxxy\Documents\Visual Studio 2010\Projects\CPC\Debug>cp inputfile_name outputfile_name

    this assumes that the executable is named cp and that the input file exists in the same folder as cp.exe. the output file, should the program run without error, would be created in the same folder as cp.exe.

    if the input or output file are not desired in the same folder as the executable, then you need to pass along full path information to where the input file is and where the output file should be created. for example,

    c:\Users\mcfoxxy\Documents\Visual Studio 2010\Projects\CPC\Debug>cp c:\Users\mcfoxxy\Documents\inputfile_name.ext c:\outputfile_name.ext

    however, at times, the command line balks at filenames/paths with spaces or long names. if you're unfamiliar with the command line, it's probably better to copy the executable to the root of a flash drive along with the input file and keep the file names to the 8.3 format. for example,

    F:\cp file1 file2

    hope that helps

Share This Page