Passing Arguments

by Selva 2008-05-08 16:02:44

In all programming language we have concept called passing arguments.Passing arguments means sending a value to funtion.When send a string or number there will be no difficulty but if pass special characters as arguments we will end with error,particularly the spcial characters ' ".

Here is example which explains this concept, using setting alias to echo command in linux

The echo command will prints the string which is passes as arguments
ex: echo "hiox"
will print: hiox

To set alias to above echo command you can give as alias h="echo \"hiox\" ".Here the " is escaped by using \ (slash) character.Now when you type: h the it will print: hiox.Now suppose you want to print hiox with in '', then you should give as alias h="echo \"'hiox'\" ".Now when you type h then 'hiox' will be printed.Suppose you want print hiox with "",then you can give as
alias h="echo "\\\"hiox\\\"" "
.Now when you type h it will print "hiox".

You can follow this way in any programming language.

Tagged in:

566
like
0
dislike
0
mail
flag

You must LOGIN to add comments