How do I access command-line arguments?

Answer Posted / reejusri

In order to access the command arguments, the main()
function must have a prototype similar to the following.
int main(int argc, char * argv[])

The names argc and argv are usually used for the
parameters, but a programmer could use different names.

Is This Answer Correct ?    6 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a program to swap two numbers without using third variable?

1079


A banker has a seif with a cipher. Not to forget the cipher, he wants to write it coded as following: each digit to be replaced with the difference of 9 with the current digit. The banker chose a cipher. Decipher it knowing the cipher starts with a digit different than 9. I need to write a program that takes the cipher from the keyboard and prints the new cipher. I thought of the following: Take the input from the keyboard and put it into a string or an array. Go through the object with a for and for each digit other than the first, substract it from 9 and add it to another variable. Print the new variable. Theoretically I thought of it but I don't know much C. Could you give me any kind of hint, whether I am on the right track or not?

1768


State the difference between x3 and x[3].

865


What do you understand by friend-functions? How are they used?

966


What is the maximum length of an identifier?

928


Why is it that not all header files are declared in every C program?

929


Explain void pointer?

824


You have given 2 array. You need to find whether they will create the same BST or not. For example: Array1:10 5 20 15 30 Array2:10 20 15 30 5 Result: True Array1:10 5 20 15 30 Array2:10 15 20 30 5 Result: False One Approach is Pretty Clear by creating BST O(nlogn) then checking two tree for identical O(N) overall O(nlogn) ..we need there exist O(N) Time & O(1) Space also without extra space .Algorithm ?? DevoCoder guest Posted 3 months ago # #define true 1 #define false 0 int check(int a1[],int a2[],int n1,int n2) { int i; //n1 size of array a1[] and n2 size of a2[] if(n1!=n2) return false; //n1 and n2 must be same for(i=0;ia1[i+1]) && (a2[i]>a2[i+1]) ) ) return false; } return true;//assumed that each array doesn't contain duplicate elements in themshelves }

2965


Why is extern used in c?

854


What is far pointer in c?

1028


What is the incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?

1203


How can a program be made to print the line number where an error occurs?

895


How do you construct an increment statement or decrement statement in C?

1007


Can you please explain the difference between exit() and _exit() function?

843


What are conditional operators in C?

839