Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9228625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:22:13+00:00 2026-06-18T05:22:13+00:00

I’m creating a very simple C program call open.c that will either: 1) List

  • 0

I’m creating a very simple C program call open.c that will either:

1) List the files in the directory that will have the files text stored in an array

I have this code so far but it doesn’t seem to work.

{ }

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:22:14+00:00Added an answer on June 18, 2026 at 5:22 am

    You need to use argv to compare the command-line arguments with "-ah" and "-ad".

    #include <string.h>
    
    if (argc > 2)
    {
      if (strcmp (argv[1], "-ah") == 0)
      {
        /* List hidden files */
      }
      else if (strcmp (argv[1], "-ad") == 0)
      {
        /* List files */
      }
      else
      {
        /* Unknown command-line argument */
      }
    }
    else
    {
      /* No command-line arguments */
    }
    

    References:

    C11 (n1570), § 5.1.2.2.1 Program startup

    If they are declared, the parameters to the main function shall obey
    the following constraints:

    — The value of argc shall be nonnegative.

    — argv[argc] shall be a null pointer.

    — If the value of argc is
    greater than zero, the array members argv[0] through argv[argc-1]
    inclusive shall contain pointers to strings, which are given
    implementation-defined values by the host environment prior to program
    startup. The intent is to supply to the program information determined
    prior to program startup from elsewhere in the hosted environment. If
    the host environment is not capable of supplying strings with letters
    in both uppercase and lowercase, the implementation shall ensure that
    the strings are received in lowercase.

    — If the value of argc is greater than zero, the string pointed to by argv[0] represents the
    program name; argv[0][0] shall be the null character if the program
    name is not available from the host environment. If the value of argc
    is greater than one, the strings pointed to by argv[1] through
    argv[argc-1] represent the program parameters.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bunch of posts stored in text files formatted in yaml/textile (from
I have just tried to save a simple *.rtf file with some websites and
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.