How to use command line arguments in c (OS: Windows)? -


i'm unable make program asks user input 3 arguments on command line: 1) operator (+, -, *, /); 2) integer (n); 3) integer (m). program should act basic calculator producing output in format: .

e.g. operator='+' n=5 m=6 output: 5+6         = 11 

if want take argument command line while user executes program can use argv vector fetch values

int main(int argc, char** argv){  } 

so if execute program follows,

./prog + 1 2 

argv contain follwing,

argv[0] = 'prog', argv[1] = '+', argv[2] = '1', argv[3] = '2', 

so can fetch each value argv , implement logic.

read this tutorial better understanding.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -