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

Explain redirection in c++?, Question 1 . Write a brief note on Aggregation...

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 .

What are the two steps that happen while i say delete p?, A: N delete p is ...

A: N delete p is a two-step procedure: it calls the destructor, and then releases the memory. The code developed for delete p is functionally similar to this (supposing p is of typ

Palindrome, A palindrome is a string that reads the same from both the ends...

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

What is namespace and explicit container, What is Namespace and Explicit ...

What is Namespace and Explicit container Namespace - Namespaces are used to group entities such as objects, classes and functions under a name. Explicit container.

C program to design text styles, Program to design text styles: Write ...

Program to design text styles: Write a C program to design different text style char *fname[] = { "DEFAULT font",                                   "TRIPLEX font",

Recursion, Given a string, print all possible palindromic partitions using ...

Given a string, print all possible palindromic partitions using recursion

Write a program that illustrate union declaration, Write a Program that ill...

Write a Program that illustrate union declaration? A C program encloses the following union declaration: union id { char color[12]; int size; } shirt, blouse; At this

Write procedure that compute recursive method, A function f is defined by t...

A function f is defined by the rule that f(n) = n if 0≤n≤3 and f(n) = f(n - 1) + 2f(n - 2) + 3f(n - 3) if n> 3. (a) Write a procedure that computes f by means of a recursive pro

How can one "reopen" std::cin & std::cout in binary mode?, A: It is impleme...

A: It is implementation dependent. Verify with your compiler's documentation. For instance, assume you wish to do binary I/O using std::cin & std::cout. Unluckily there is no st

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