We can explain this by simple C++ program.

The following program will get two numbers and print the addition.
$ more test_args.cpp
#include<iostream>

int main(int argc, char* argv[])
{
  int a=0,b=0;
  std::cout << "Enter First Number : ";
  std::cin >> a;
  std::cout << "Enter Second Number : ";
  std::cin >> b;
  std::cout << "Addition of these two numbers : " << a + b << "\n";
  return 0;
}

You can run this program as follows for the values 40 and 20, it will print
60.
$ ./test_args.out
Enter First Number : 40
Enter Second Number : 20
Addition of these two numbers : 60

There is a text file which has this 40 and 60 value inside.
$ more test_args.txt
40
20

You can pass this text file to this program to get these values.
$ ./test_args.out < test_args.txt
Enter First Number : Enter Second Number : Addition of these two numbers :
60

This kind of approach will be very useful when we want to run the same
program with different data. Even with this we can automate to run a
program with different data.

If you still have any queries, please let me know.

Thanks,



On Sun, Apr 7, 2013 at 12:25 AM, [email protected] <[email protected]>wrote:

> Best example could be cat command. Or providing inputs.
>
> ----------
> Nokia మెసేజింగ్ ఉపయో. నా ఫోను నుండి పంపబడి.
>
> ------Original message------
> From: Shrinivasan T <[email protected]>
> To: "ILUG-C" <[email protected]>
> Date: Saturday, April 6, 2013 4:52:47 PM GMT+0000
> Subject: [Ilugc] where we use input redirection?
>
> We are using the output redirection > in many situations to redirect the
> outputs to a file or a pipe.
>
> I never used the input redirection.
>
> Can anyone explain it with some examples?
>
> --
> Regards,
> T.Shrinivasan
>
>
> My Life with GNU/Linux : http://goinggnu.wordpress.com
> Free/Open Source Jobs : http://fossjobs.in
>
> Get CollabNet Subversion Edge :     http://www.collab.net/svnedge
> _______________________________________________
> ILUGC Mailing List:
> http://www.ae.iitm.ac.in/mailman/listinfo/ilugc
>
> _______________________________________________
> ILUGC Mailing List:
> http://www.ae.iitm.ac.in/mailman/listinfo/ilugc
>



-- 
S. John Christopher,
செ.ஜான் கிறிஸ்டோபர்
Team Leader,
Checktronix India Pvt Ltd,
Dharmapuri.
http://tamilanjohn.blogspot.com/
http://spaces.msn.com/johnchristophers/
_______________________________________________
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc

Reply via email to