Help Needed

This is a discussion on Help Needed within the C Programming forums, part of the General Programming Boards category; ok, I am a newbie to c & I want to make a basic program in ms-dos. But I can ...

  1. #1
    Unregistered
    Guest

    Question Help Needed

    ok, I am a newbie to c & I want to make a basic program in ms-dos. But I can never seem to execute commands properly, check this out:

    <!-- Crappy Code Begin --!>
    #include <stdio.h>

    main()
    {
    system("dir");
    }
    <!-- Crappy Code End --!>

    Now when I compile & run this thing it never works, all it is supposed to do is the 'dir' command in ms-dos but all I get is a blank black screen.

    What am I doing wrong here people?

  2. #2
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680
    Works fine on my machine (Windows NT/VC++ 6.0):
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    int main()
    {
      system("dir");
      getchar();
      return 0;
    }

  3. #3
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    Also works fine with me (Windows 98/GCC 3.03.

    What OS and compiler are you using?

  4. #4
    Unregistered
    Guest

    I am using

    I am using Windows 98 with the Miracle C compiler, But that code worked fine, thanx. Must have just been the return 0;

  5. #5
    Unregistered
    Guest
    ahh crap, it don't work but I thought it did

    I was typing dir.exe (the name of the program) to execute it & it just brang up a list of directories, but when I renamed it & executed it again I found out that it didn't actually work.

    Anybody know what the problem is?

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,532
    > Miracle C compiler
    This isn't an ANSI-C compiler - you're going to miss out on some things.

    http://www.compilers.net/
    http://www.thefreecountry.com/developercity/index.html
    http://www.borland.com/bcppbuilder/freecompiler/

  7. #7
    Unregistered
    Guest

    Thanx

    ok thanx, it was just the compiler . I can now execute commands like dir, time & date in ms-dos.

    But how would I go about doing commands such as cd c:\?
    I tried system("cd c:\"); without any luck.

    This is the last question I will ask.

    Many Thanx

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. free needed or not?
    By quantt in forum Linux Programming
    Replies: 3
    Last Post: 06-25-2009, 09:32 AM
  2. C Programmers needed for Direct Hire positions
    By canefan in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 09-24-2008, 11:55 AM
  3. lock needed in this scenario?
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 05-25-2008, 07:22 AM
  4. Releasing a program - what is needed? A few Q's
    By ulillillia in forum Tech Board
    Replies: 9
    Last Post: 04-28-2007, 12:18 AM
  5. C++ help needed
    By Enkindu in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 08-31-2004, 11:24 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21