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

Assignment Help:

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;

        exit(1);

        }

 

    int path;                      

    Directory::sortOrder sorting = Directory::byName;

 

    if( argc != 3 )

        path = 1;

    else

        {

        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;

}


Related Discussions:- Sorted directory - c++ program

C++ Program Please see where i do mistake, #include #include #include ...

#include #include #include #include #include class Employee { private: char *Name; //Set them as pointers... int IdNumber; char *Department; char *Position; public: voi

Should i call a destructor explicitly on a local variable?, Should I call a...

Should I call a destructor explicitly on a local variable?

#coding, Smugglers are becoming very smart day by day. Now they have develo...

Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

C program to returns the string, Program is to take two arguments and retur...

Program is to take two arguments and returns the string: Program is to take two arguments and returns the string which is larger the larger string has larger ascii value invok

Why should i employ new instead of truthful old malloc()?, Why should I emp...

Why should I employ new instead of truthful old malloc()? A: Constructors/destructors, type safety, overridability. Constructors/destructors: unlike malloc(sizeof(Fred)), new

Areaundercurve.c, Write a program to find the area under the curve y = f(x)...

Write a 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 betw   Solution:

Statistical and Numerical methods using C++–, An experiment succeeds twice ...

An experiment succeeds twice as often as it fails. Find the chance that in the next six trials there will be at least four successes.

Flash my terminal vx670, Flash my terminal vx670 Project Description: ...

Flash my terminal vx670 Project Description: Have VeriFone software need it to communicate with the vx670 through com port 1 it is not talking I'm not sure why have all the r

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd