Using Buffer

This is a discussion on Using Buffer within the C++ Programming forums, part of the General Programming Boards category; How can I obtain list of current working directory--put them into a buffer, say size 1024 bytes, and then print ...

  1. #1
    JC101
    Guest

    Question Using Buffer

    How can I obtain list of current working directory--put them into a buffer, say size 1024 bytes, and then print them out on a temp file one per line?

    This is my attempt:

    #include <stdio.h>

    char buffer[ 1024 ];

    if (( "ls - l", buffer, 1024 ) < 0 )

    printf( "ls: %s\n", buffer );

  2. #2
    Registered User
    Join Date
    Nov 2002
    Posts
    491
    The current working directory is the directory you are currently in. Do you mean opbtain a list of the files in the direcotry you are on? If so this is OS dependent. If you are in linux:
    man readdir
    man opendir
    man closedir

    If you are in windows go to http://msdn.microsoft.com/ and look for GetFirstFile (I think) and GetNextFile.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 10-29-2006, 05:04 AM
  2. writing a pack-style function, any advices?
    By isaac_s in forum C Programming
    Replies: 10
    Last Post: 07-08-2006, 09:09 PM
  3. buffer contents swapping
    By daluu in forum C++ Programming
    Replies: 7
    Last Post: 10-14-2004, 03:34 PM
  4. Tetris Questions
    By KneeGrow in forum Game Programming
    Replies: 19
    Last Post: 10-28-2003, 11:12 PM
  5. Console Screen Buffer
    By GaPe in forum Windows Programming
    Replies: 0
    Last Post: 02-06-2003, 05:15 AM

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