C Programming - Command Line Arguments - Discussion

Discussion Forum : Command Line Arguments - Find Output of Program (Q.No. 9)
9.
What will be the output of the program (myprog.c) given below if it is executed from the command line?
cmd> myprog friday tuesday sunday
/* myprog.c */
#include<stdio.h>

int main(int argc, char *argv[])
{
    printf("%c", *++argv[1]);
    return 0;
}
r
f
m
y
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
12 comments Page 2 of 2.

A$tro said:   9 years ago
This program will print an output on both environment Linux/windows-and I think we can define an array size using either variable/macros/const.

As I've tried to define the max as shown:

int max =20;
C Const int max=20; ------------- and it works on both cases.

So may be the error depends on the standard ANSCI CS99 etc.

Vaishali said:   9 years ago
Is there any differences between **++argv and *++argv?


Post your comments here:

Your comments will be displayed after verification.