C getting input from CMD -
C getting input from CMD -
how input using prompt? tried compiling code bellow "a.exe" , executing cmd "gcc a.exe 5", doesn't output number supposed to.
#include <stdio.h> int main(int a) { printf("%d\n", a); homecoming 1; }
have done wrong when installing compiler or trying run wrong?
your main()
parameters wrong, should way:
int main(int argc, char **argv) { if(argc > 2) { printf("%s\n", argv[2]); } else { printf("no arguments\n"); } }
note int argc
represents number of parameters , char **argv
array containing parameters, strings, including "gcc", "a.exe", etc. in case, if run programme way: gcc a.exe 5
, parameters be: argc = 3, argv = ["gcc", "a.exe", "5"]
c
Comments
Post a Comment