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

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -