The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Getting error in command line arguments sunitachoudhury Shell Programming and Scripting 9 01-14-2009 09:13 PM
command line arguments skooly5 Shell Programming and Scripting 1 04-07-2008 04:49 AM
i want to list all command line arguments except naree Shell Programming and Scripting 3 03-31-2008 12:11 PM
arguments in command line rrs UNIX for Dummies Questions & Answers 6 07-28-2006 07:44 AM
Command Line Arguments roba909 UNIX for Dummies Questions & Answers 7 01-19-2006 01:46 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-02-2006
bankpro bankpro is offline
Registered User
  
 

Join Date: Jan 2006
Location: Mumbai
Posts: 43
command line arguments

Hi

How to pass multi line text as a command line argument to a program.


(i.e)


./a.out hi this is sample 0 file1
where
hi this is sample should be stored in argv[1]
0 in argv[2] and so on...
  #2 (permalink)  
Old 02-02-2006
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
Based on your current input,

./a.out "hi this is sample" "0" ...## and so on.

Enclose space seperated arguments to prevent the shell from interpreting them.
  #3 (permalink)  
Old 02-02-2006
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,953
and what if " itself is the argument

./a.out "simple" "\""
  #4 (permalink)  
Old 02-02-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,763
Code:
kcsdev:/home/jmcnama> cat a.c
int main(int argc, char *argv[])
{
        int i;
        for (i=0;i<=argc;i++) printf("%s\n", argv[i]);
        return 0;
}
kcsdev:/home/jmcnama>cc a.c
kcsdev:/home/jmcnama> a.out "simple test" "b" '"'
a.out
simple test
b
"
kcsdev:/home/jmcnama> a.out "simple test" "b" \"
a.out
simple test
b
"
M -
This is a shell question ,not a C question, IMO.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:11 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0