LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-29-2015, 08:58 AM   #1
lalitaddiwar
LQ Newbie
 
Registered: Apr 2015
Posts: 7

Rep: Reputation: Disabled
How can I create C program in C in which i can pass the user agruments?


Hello friends,
I need to know that how can i pass arguments in c program using Linux gcc and gdb?
For example, int main(int argc char *argv[])
{ any program body}
I want to know the steps how to pass the arguments while using gdb?
For consideration please explain me using factorial program.
Thank You.
 
Old 05-29-2015, 09:07 AM   #2
/dev/random
Member
 
Registered: Aug 2012
Location: Ontario, Canada
Distribution: Slackware 14.2, LFS-current, NetBSD 6.1.3, OpenIndiana
Posts: 319

Rep: Reputation: 112Reputation: 112
Quote:
Originally Posted by lalitaddiwar View Post
Hello friends,
I need to know that how can i pass arguments in c program using Linux gcc and gdb?
For example, int main(int argc char *argv[])
{ any program body}
I want to know the steps how to pass the arguments while using gdb?
For consideration please explain me using factorial program.
Thank You.
gdb --args myprogram arg1 arg2 arg3
 
Old 05-29-2015, 10:06 AM   #3
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Or:

Code:
gdb myprogram
run args
 
Old 06-01-2015, 06:44 AM   #4
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 8,982
Blog Entries: 13

Rep: Reputation: 4101Reputation: 4101Reputation: 4101Reputation: 4101Reputation: 4101Reputation: 4101Reputation: 4101Reputation: 4101Reputation: 4101Reputation: 4101Reputation: 4101
OR:
Code:
gdb program
(gdb) set args arg1 arg2 ...
NOTE that you should have compiled using the -ggdb flag.
Quote:
Originally Posted by lalitaddiwar View Post
For consideration please explain me using factorial program.
What do you mean here? You want someone to cite a factorial program, or write one for you and then use that as an example?

Last edited by rtmistler; 06-01-2015 at 06:47 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Create a user defined shell in Ubuntuusing c program parmishr Linux - Newbie 17 09-11-2011 05:54 AM
[SOLVED] Make script that runs program as another user with pass? LuxLuv Programming 4 06-08-2010 10:34 AM
how to pass MySQL user/pass securely in shell script? digity Linux - Newbie 5 01-07-2010 05:48 AM
which C++ library is used to get the options user pass for program TruongAn Programming 7 07-05-2005 04:56 PM
Pass SCP User passward in shell program michaelyu33 Programming 3 03-18-2005 12:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration