Write a c program to convert binary to decimal using command line arguments?

Please provide the solution for this in command line arguments. The answer will be added from the comments.

Here is basic C program without command line –

[code language=”cpp”] 
#include<stdio.h>
int main(int argc, char *argv[]){
int num,binary,decimal=0,rem,base=1;
num=atoi(argv[1]);
binary=num;
while(num>0){
rem=num%2;
decimal+=rem*base;
num=num/10;
base=base*2;
}
printf("%d",decimal);
return 0;
}
[/code]

 

Check all other command Line Programs for TCS here on our Command line Programming Dashboard