Thread: Passing response to command line prompt from C

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    27

    Passing response to command line prompt from C

    Hello, I'm trying to write a utility for something I'm working on. But I ran into this problem. I'm calling the system() function to perform xcopy. However, I don't think xcopy has an option that will tell it to automatically not overwrite files already there in the destination. It prompts for a user response whether to overwrite or not.

    My question is, is there anyway I can pass a response from my C program to the command line? (Say I want to pass a 'no' on the overwrite?)

    Or is there a better way to get xcopy not to overwrite stuff that's already in the destination?

    Thanks a lot for your help.

  2. #2
    The Richness... Richie T's Avatar
    Join Date
    Jan 2006
    Location
    Ireland
    Posts
    469
    Perhaps this might help - look at the /y flag.
    No No's:
    fflush (stdin); gets (); void main ();


    Goodies:
    Example of fgets (); The FAQ, C/C++ Reference


    My Gear:
    OS - Windows XP
    IDE - MS Visual C++ 2008 Express Edition


    ASCII stupid question, get a stupid ANSI

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newb Question on Passing Objects as Parameters
    By Mariano L Gappa in forum C++ Programming
    Replies: 12
    Last Post: 11-29-2006, 01:08 PM
  2. Sorting out cause of wrong response from class members
    By imCrushedByCode in forum C++ Programming
    Replies: 11
    Last Post: 04-18-2006, 12:30 AM
  3. Removing spaces from a "string"
    By sytaylor in forum C++ Programming
    Replies: 20
    Last Post: 03-25-2004, 10:14 AM
  4. Password prompt in unix w/o \b
    By rafe in forum C++ Programming
    Replies: 1
    Last Post: 10-09-2002, 08:54 AM
  5. Array, reading in response etc...
    By mattz in forum C Programming
    Replies: 4
    Last Post: 12-05-2001, 11:41 AM