Sorted directory - c++ program, C/C++ Programming

Sorted directory - C++ program:

Write a program in c to sorting a directory.

int main( int argc, char *argv[] )


    if( argc < 2 || argc > 3 )


        cerr << "Usage:  directry [options] filespec" << endl << endl;

        cerr << "Options:" << endl;

        cerr << "\t-sd\tsort by date" << endl;

        cerr << "\t-sn\tsort by name" << endl;

        cerr << "\t-ss\tsort by size" << endl;




    int path;                      

    Directory::sortOrder sorting = Directory::byName;


    if( argc != 3 )

        path = 1;



        path = 2;

        if( strcmp( argv[1], "-sn" ) == 0 )

            sorting = Directory::byName;

        else if( strcmp( argv[1], "-sd" ) == 0 )

            sorting = Directory::byDate;

        else if( strcmp( argv[1], "-ss" ) == 0 )

            sorting = Directory::bySize;



    Directory sortedDirectory( argv[path], sorting );

    cout << sortedDirectory;

    return 0;


Posted Date: 10/19/2012 3:09:14 AM | Location : United States

Related Discussions:- Sorted directory - c++ program, Assignment Help, Ask Question on Sorted directory - c++ program, Get Answer, Expert's Help, Sorted directory - c++ program Discussions

Write discussion on Sorted directory - c++ program
Your posts are moderated
Related Questions
Refactoring Project Description: TASK 1 - DESIGN ALGORITHM You are required to design a suitable solution algorithm by using structured chart, pseudocode or flowchart. Thi

Question 1 . Write a brief note on Aggregation Question 2 . Discuss briefly on constructors Question 3 . What are the important advantages of Inheritance? Question 4 .

how to use a pointer variable?

Write a sequence of instructions that transfers data from memory to an external I/O device by using channel 3 of the 8237 DMA controller. Transfer from 20000H-20FFFH.

I have a program and I want someone to fix it for me by using basic c language program.

Write a c++ program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points c

how we write decision tables, flowcharts,pseudocode,and algorithm in result management system

Aim: To implement a program for following string operations: Length of String. String Concatenation. Substring (provide start index and length) Find character a

Write the statements which are used to connect PHP with MySQL? Statements which can be used to connect PHP with MySQL is: $conn = mysql_connect('localhost'); echo $co