c - Why does console program print directory list rather than command line arguments? -


i doing exercise question 5-10 in k&r (the c programming language), , unable understand behavior of simple c code.

#include<stdio.h>  int main(int argc, char *argv[]) {     int ctr = 1;     if(argc == 1)         printf("usage: reverse polish notation evaluator\n");     else {         printf("total count : %d\n", argc);         while(argc-- > 1)             printf("%s\n", argv[ctr++]);     }         return 0; } 

this code working fine arguments except " * " (without quotes) character. when " * " given argument, code prints name of files present in directory. default behavior or has meta characters or doing wrong ?

this has shell. shell expands * character space-separated list of files in current working directory.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -