Thread: Feeding Source Code and Passing filename as a command line parm.

  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    13

    Feeding Source Code and Passing filename as a command line parm.

    Hi i have a filename here,its an interpreter of C to run it or to show its output it says feed it with source code as a file and pass the filename as a command line parameter can you teach me how to do that??? any concerns will be appreciated..tnx

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    You asked this already -> Command Line Parameter
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Aug 2011
    Posts
    13
    But i can't open the filename or trying to execute it...

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Well you're just going to have to post some code.
    Because starting new threads on the same subject and hoping we can guess just isn't going to work.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by niwradz View Post
    But i can't open the filename or trying to execute it...
    Then you should post the code you wrote trying to do this and we can help correct it for you.

    There is no point providing you with another example when there are already thousands on line. If those did not help, we need to go through this step by step, and the first step is seeing what it is you've done wrong.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  6. #6
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    First read this... Introduction to the Windows Command Prompt

    Open your command shell... (on windows type WIN+R -> cmd -> OK)

    Use the CD command to move to the folder with your program in it...
    Type the program's name followed by the filename you want to open.

    How do you expect to program a computer you don't even know how to operate?

  7. #7
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Salem View Post
    Well you're just going to have to post some code.
    Because starting new threads on the same subject and hoping we can guess just isn't going to work.
    I'm guessing he doesn't know how to feed the file he wrote to the interpreter...

  8. #8
    Registered User
    Join Date
    Aug 2011
    Posts
    13

    Wink whew

    is this correct?
    my programs name is try
    the filename is snotc
    i type the command shell like this: c:\>try.exe snotc
    is that correct??

  9. #9
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Assuming the filename is indeed snotc (as opposed to snotc.txt or snotc.q or whatever) and that the file lives in the current working directory, then yes.

  10. #10
    Registered User
    Join Date
    Aug 2011
    Posts
    13
    then should it be this correct
    assuming argy[1] is snotc.... what should i do to show that the snotc is working??

  11. #11
    Registered User
    Join Date
    Aug 2011
    Posts
    13
    Quote Originally Posted by CommonTater View Post
    I'm guessing he doesn't know how to feed the file he wrote to the interpreter...
    yes i dont know how to feed the file..please tell me how...

  12. #12
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Do you know how to work with files in C?

  13. #13
    Registered User
    Join Date
    Aug 2011
    Posts
    13
    Quote Originally Posted by tabstop View Post
    Do you know how to work with files in C?
    probably not....

  14. #14
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    Quote Originally Posted by niwradz View Post
    then should it be this correct
    assuming argy[1] is snotc.... what should i do to show that the snotc is working??
    And it's "argv[1]" not "argy[1]"
    [Hoping it's a typo, not copy 'n paste from code]

  15. #15
    Registered User
    Join Date
    Aug 2011
    Posts
    13
    Quote Originally Posted by itCbitC View Post
    And it's "argv[1]" not "argy[1]"
    [Hoping it's a typo, not copy 'n paste from code]
    hahah sori i ddn't see it maybe my hands were too fast that my eyes can't notice it....T_T

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. command line source navigation tools
    By ceti331 in forum Linux Programming
    Replies: 2
    Last Post: 07-21-2008, 09:36 AM
  2. how to have the filename as a command line parameter.
    By Frank_Rye in forum C Programming
    Replies: 2
    Last Post: 10-17-2005, 06:18 AM
  3. passing in * from command line
    By eth0 in forum C Programming
    Replies: 5
    Last Post: 09-13-2005, 10:52 AM
  4. Command Line Variable Passing (like in DOS)
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 08-31-2002, 07:31 AM
  5. passing command line argument
    By Tim in forum C Programming
    Replies: 3
    Last Post: 01-30-2002, 05:59 PM

Tags for this Thread