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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:51:01+00:00 2026-06-06T21:51:01+00:00

There is an abnormality in the value of argc when ‘*’ is passed as

  • 0

There is an abnormality in the value of argc when ‘*’ is passed as one of the arguments calling a program in c.
I made a simple code in c and saved it as ‘test2.c’.Here is the following code of ‘test2.c’—

#include<stdio.h>
#include<stdlib.h>
int main(int argc,char* argv[])
{
printf("%d\n",argc);return 0;
}

I compiled it and call it as–

dev@ubuntu:~$ gcc test2.c -o t
dev@ubuntu:~$ ./t *
31

So, i am getting the argument count value as 31; whereas if ‘*’ is replaced by any other binary operator ; the value of argc is 2(which is also logically correct).

dev@ubuntu:~$ ./t +
2

I am not able to fathom why is it so….and there is one more interesting thing.when ‘-‘ is used in place of ‘‘;the answer is 2(which is again logically correct)

dev@ubuntu:~$ ./t -*
2

Can anyone help me in this;thanks in advance.

  • 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-06T21:51:03+00:00Added an answer on June 6, 2026 at 9:51 pm

    Its just the shell expansion. The shell will expand * to the filenames (directories included) in the current directory in which the program is executing.

    + or ; does not have special interpretations therefore they are considered as normal strings, but * has special interpretation, thus it is expanded to the list of all files in current directory, which is passed to your program.

    Try using

    ./t '*' or ./t \*

    This stops special interpretation of *. The first one used the bash (looks like you are in bash) single quote, which does not make any special interpretation inside the patterns in the quote, and the next one uses escape sequence.

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

Sidebar

Related Questions

My program/process exited abnormally? I doubt something is wrong with the following code: There
There are two table s : one is the master and one the detail
I return a error code if my program was abnormally terminated (via exit()). For
There are many similar questions to this one, but they all ask about setting
There is a problem in some browsers, for example, Firefox. Code: $(document).ready(function(){ $(this).keydown(function(e){ //
If PHP session is created before login, there will be one session file created
There was some code like this: // Convenience to make things more legible in
I just introduced threads to a Perl program, where one of its modules was
There is a moment in my app, that I need to force to show
There is a column that exists in 2 tables. In table 1, this column

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.