Thread: Handling scanf/cin at executin time of program

  1. #1
    Registered User
    Join Date
    Apr 2011

    Question Handling scanf/cin at executin time of program


    I need some information regarding how to handle scanf values while executing the program itself.
    For example:
    main(int argc, char* argv[])
    char str[20];
    printf("first argument: %s",__argv[1]);
    printf("Second argument: %s",__argv[2]);
    printf("Enter your name:");
    suppose the program exe name is BYTE then in order to execute from command prompt we need to give:
    BYTE 1arg 2arg ->ENTER
    it asks to enter your name

    My question is how can i give name at executing itself
    BYTE 1arg 2arg << James Bond

    will it work???
    Last edited by Salem; 04-10-2011 at 12:12 AM. Reason: added [code][/code] tags - learn to use them yourself

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Not <<, but |

    echo ThisIsMyVeryLongNameDesignedToBlowUpYourProgramUsi ngTheUnsafeGetsFunction | BYTE 1arg 2arg
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 18
    Last Post: 05-27-2011, 04:16 PM
  2. time program showing time since epoch?
    By cus in forum Linux Programming
    Replies: 5
    Last Post: 01-10-2009, 01:56 PM
  3. Handling FPS / time...
    By mikahell in forum C++ Programming
    Replies: 5
    Last Post: 06-17-2006, 07:00 PM
  4. Signal Handling program
    By langdoy in forum C Programming
    Replies: 4
    Last Post: 03-26-2002, 12:09 AM