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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:00:54+00:00 2026-06-12T20:00:54+00:00

int main(int argc,char **argv){ for (argc–, argv++; argc > 0; argc -= argCount, argv

  • 0
int
main(int argc,char **argv){

for (argc--, argv++; argc > 0; argc -= argCount, argv += argCount) {
      argCount = 1;
      switch (argv[0][1]) {
      case 'q':
        testnum = atoi(argv[1]);
        argCount++;
        break;
      default:
        testnum = 1;
        break;
      }
    }
//...............

my question is what does the argv[0][1] mean and the condition in for() confused me i mean for (argc--, argv++; argc > 0; argc -= argCount, argv += argCount)

//thanks guys….**argv[0][1] should be argv[0][1],thats my mistake not the code writers.

  • 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-12T20:00:55+00:00Added an answer on June 12, 2026 at 8:00 pm

    argv[0] represents the name of the program as it was invoked on the command line. If you typed ./myprogram --help, then argv[0] would be “./myprogram”.

    argv[0][1] will be the second character of that string, ‘/’ in the example above.


    Let’s see that for (argc--, argv++; argc > 0; argc -= argCount, argv += argCount):

    It initializes the loop by doing argc-- then argv++ (argv now points to the second user parameter string) and argc declares an argument less.

    The loop is for all arguments argc>0, and at every iteration, the number of treated arguments argCount is taken off the number of all arguments argc. That makes sense.

    However switch (**argv[0][1]) doesn’t make any sense, argv[0][1] is a char, as seen before, not a pointer, so it cannot be dereferenced.

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

Sidebar

Related Questions

This is my program: int main(int argc, char *argv[]){ if(argc != 2){ printf(Uso: ./server
This is my code: int main(int argc, char *argv[]){ FILE *fp; char *tmp, *tmp2,
I have the following code: int main(int argc, char** argv) { onelog a; std::cout
See this example! int main( int argc, char ** argv ) { int *ptr
I have a, int main (int argc, char *argv[]) and one of the arguements
hej.h void hej(); hej.m void hej(){} main.mm #import hej.h int main(int argc, char *argv[])
#include <stdio.h> int main(int argc, char *argv[]) { long* fp; while(1) { fp =
Following simplified code snippet: #include <QtGui> int main(int argc, char **argv) { QApplication app(argc,
I am running this code: #include <iostream> #include <cstddef> int main(int argc, char *argv[]){
#include<stdio.h> #include<math.h> int main(int argc, char **argv){ // read in the command-line argument double

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.