Handling scanf/cin at executin time of program

This is a discussion on Handling scanf/cin at executin time of program within the C Programming forums, part of the General Programming Boards category; Hi, I need some information regarding how to handle scanf values while executing the program itself. For example: Code: main(int ...

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    1

    Question Handling scanf/cin at executin time of program

    Hi,

    I need some information regarding how to handle scanf values while executing the program itself.
    For example:
    Code:
    main(int argc, char* argv[])
    {
    
    char str[20];
    printf("first argument: %s",__argv[1]);
    printf("Second argument: %s",__argv[2]);
    
    printf("Enter your name:");
    gets(str);
    
    )
    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
    like
    BYTE 1arg 2arg << James Bond

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

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,755
    Not <<, but |

    Like
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 18
    Last Post: 05-27-2011, 05: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, 08:00 PM
  4. Signal Handling program
    By langdoy in forum C Programming
    Replies: 4
    Last Post: 03-26-2002, 12:09 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21