Results 1 to 3 of 3
in a shell script if i have a string eg: "how are you" how do i pass it to the c program command line arguments such as argv[0]="how are you"....hhow ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 12-10-2007 #1Just Joined!
- Join Date
- Dec 2007
- Location
- bangalore
- Posts
- 38
command line arg
in a shell script if i have a string eg: "how are you" how do i pass it to the c program command line arguments such as argv[0]="how are you"....hhow to pass this string and recieve it in one piece in c prog....................plz reply quick
- 12-10-2007 #2Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
One of the many results with a quick search with Google:
The GNU C Programming Tutorial
Regards
- 12-10-2007 #3
C's argv[] array is its commandline arguments. So in a script, I would do:
And the argv[] array for my_program will be:Code:#!/bin/bash arg=another argument ./my_program arg1 arg2 arg3 "$arg"
Code:argv[0] = ./my_program argv[1] = arg1 argv[2] = arg2 argv[3] = arg3 argv[4] = another argument


Reply With Quote

