Thread: system() no go

  1. #1
    Unregistered
    Guest

    system() no go

    HI guys.
    Can someone please tell me why I can't use the system() function i've tried all sorts of conbinations i.e.
    system("dir"); list whole directory */
    system("c:\*.txt) /* list text files in directory */
    ...
    ...
    and all to no avail the prog does not come back with errors just nothing happens.

    dos prog on win95 machine.

    thx guys.

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Have you included the <stdlib.h>??

    What compiler are you using??

  3. #3
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    > system("c:\*.txt)

    Also, in this case I think you need double backslashes and to close your quote.

  4. #4
    Unregistered
    Guest
    yes included <stdlib.h>
    and closed my double quotes
    compiler: borland

  5. #5
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    ok........and you are running this from the command prompt?

  6. #6
    Unregistered
    Guest
    no not from the command prompt thats fine, running it from within a c program.

    if I type dir or dir *.txt they run fine but not in a prog.

  7. #7
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    yes....but are you exceuting your program from the prompt?

  8. #8
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Code:
    #include <stdlib.h>
    
    int main(int argc, char *argv[])
    {
    system("dir c:\\");
    return 0;
    }
    This compiles and runs fine on Win98 using DevC++......

    Any differences??

  9. #9
    Unregistered
    Guest
    no not executing from the prompt, running the prog straight from the compiler i.e. going to the menu and selecting run or by pressing ctrl/f9.

  10. #10
    Unregistered
    Guest
    also i,ve got

    int main() /* any problem with this

  11. #11
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Well go to the dir your program is in....and run it from the prompt.... see what happens

  12. #12
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Originally posted by Unregistered
    also i,ve got

    int main() /* any problem with this

    Nah.....unless you want to take command parameters

  13. #13
    Unregistered
    Guest
    ok I get back command or filename.

  14. #14
    Unregistered
    Guest
    BIG THANKS fordy for all the help got to go for now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File System Implementation
    By dodgeviper in forum C Programming
    Replies: 9
    Last Post: 11-16-2007, 01:04 PM
  2. Using system icons
    By @nthony in forum Windows Programming
    Replies: 1
    Last Post: 01-13-2007, 07:56 PM
  3. Linux database system needed
    By BobS0327 in forum Tech Board
    Replies: 7
    Last Post: 06-11-2006, 03:56 PM
  4. BIOS system and memory allocation problem
    By beely in forum Tech Board
    Replies: 9
    Last Post: 11-25-2003, 07:12 AM
  5. Number system base M, print numbers N digits wide...
    By biterman in forum C Programming
    Replies: 12
    Last Post: 11-19-2001, 04:31 AM