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 7030691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:42:18+00:00 2026-05-28T00:42:18+00:00

I discovered that it is possible to create command-line programs via C++. I am

  • 0

I discovered that it is possible to create command-line programs via C++.
I am a C++ rookie and I know only basic things, but still, I want to use it to create new command-line programs.
Now, I have discovered this code:

//file name: getkey.exe
#include <conio.h>
int main(){
    if (kbhit())  return getche() | ('a' - 'A');
}

which surprisingly simple, and it runs like this: getkey
But it doesn’t explain how to create a command with arguments (like: getkey /? or /K or /foo…)

How to create a command-line program with arguments? << Main question

  • 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-05-28T00:42:19+00:00Added an answer on May 28, 2026 at 12:42 am

    define the function main as taking these two arguments:

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

    argc will be populated with the number of arguments passed and argv will be an array of those parameters, as null-terminated character strings. (C-style strings)

    The program name itself will count as the first parameter, so getkey /? will set argc to 2, argv[0] will be “getkey” and argv[1] will be “/?“

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

Sidebar

Related Questions

Is it possible to create Eclipse plugins that auto-discover eachother? I am developing a
I discovered that it is possible to extract the hard-coded strings from a binary.
I only just recently discovered that Visual C++ 2008 (and perhaps earlier versions as
I've really only just discovered that you can use /** @blah */ comments to
I have discovered that I can create UILabel much faster than UITextField and I
I discovered that one of the tables of a legacy db I'm working on
We recently discovered that the Google Maps API does not play nicely with SSL.
Today I discovered that my fresh installation of Apache HTTP Server is able to
I've discovered that any time I do the following: echo '<a href=http:// title=bla>huzzah</a>'; I
I've discovered that cElementTree is about 30 times faster than xml.dom.minidom and I'm rewriting

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.