Results 1 to 5 of 5

Thread: Make a program behave on the basis of input given dring execution

  1. #1
    Join Date
    Dec 2010
    Posts
    49

    Make a program behave on the basis of input given dring execution

    I am doing a bit of programming, I am clear with the concepts of C language , but now I am learning object oriented language , right now I am learning just wanted to know if there is any way so that I can make my program behave on the basis of the input being given while it is being executed , that is I want to execute the program and behave it upon the input that I give to it , so it would be an add on help for me if you can provide solution to my query being posted

  2. #2
    Join Date
    May 2009
    Posts
    637

    Re: Make a program behave on the basis of input given dring execution

    Yes you can definitely do it with the help of a command line arguments . You can give command line arguments to C# programs. The program takes the values stored in the parantheses and takes arguments in the order of index 0 i.e arg[0] and index 1 i.e arg[1] and this goes so on . This indexes will store the values being passed when the input is given after the program is executed

  3. #3
    Join Date
    May 2009
    Posts
    543

    Re: Make a program behave on the basis of input given dring execution

    Code:
    class NewProg
    {
    	Public static void Main(string[] args)
    	{
    		System.Console.WriteLine("First argument  " + args[0]+"   second argument "+args[1]);
    		Console.Read();
    	}
    }
    Here in the given code the main method is the entrypoint of the program and it is static and th command line arguments are passed to this main method and this args take the input value and store in them , , here the o and 1 indexer are actually the place holders and will take the respective positions in the array.

  4. #4
    Join Date
    Apr 2009
    Posts
    488

    Re: Make a program behave on the basis of input given dring execution

    In C++ it is likely to take command line arguments. Command-line arguments are mostly passed in a code in command-line operating systems such as DOS or Linux , and are given in to the code through the operating . To make use of command line arguments in your code, you should first be aware of the full declaration of the main method , which before has accepted no arguments.

  5. #5
    Join Date
    May 2009
    Posts
    511

    Re: Make a program behave on the basis of input given dring execution

    Programming languages like C, C++ and Java let a program to take the command-line arguments by managing them as string parameters in the main method. It is actually a code that is being invoked, and a program being written van take or accept as many as command line arguments as they want , this mostly depends on the the necessity of the program , sometime they may accept it or sometime ignore it.

Similar Threads

  1. Execution of program can not find the file
    By Gunner 1 in forum Software Development
    Replies: 5
    Last Post: 13-01-2010, 11:42 AM
  2. Difficulty in input program
    By Carnie in forum Software Development
    Replies: 3
    Last Post: 04-12-2009, 01:13 PM
  3. Delay in execution of C program?
    By Chrisch in forum Software Development
    Replies: 4
    Last Post: 03-10-2009, 10:52 AM
  4. Problem with variable input in C program
    By Zool in forum Software Development
    Replies: 2
    Last Post: 14-05-2009, 09:43 PM
  5. Why C, C++ program execution starts with main()
    By RadhaV in forum Software Development
    Replies: 4
    Last Post: 13-02-2009, 08:08 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,238,086.13773 seconds with 17 queries