On running the below code, it stucks after displaying the argv[0], argv[1] and argv[2] line. Further flow of code is blocked at this point, can any one help why it is stopping its execution or is it entering into an infinite loop.
#include <stdio.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <string.h> #include <stdlib.h> #include "p8log.h" #include <errno.h> int main(int argc, char* argv[]) { char* PORT; char* IPADDR; printf("Arg Count=%d\n",argc); printf("Arguments are=%s,%s,%s\n",argv[0],argv[1],argv[2]); printf("HELLO"); PORT=argv[1], printf("WORLD"); IPADDR=argv[2]; printf("START"); printf("port num=%s",PORT); printf("IP ADDR=%s",IPADDR); printf("END"); /* some algorithm of calculation */ return 0; } Execution
./file-exe 11111 127.0.0.1 Output
Arg Count=3 Arguments are=./file-exe,11111,127.0.0.1
ENDis written to the output ever reached?\nto allprintf's. Post the input you enter, then the output you see.$ ./a.exe 11111 127.0.0.1Arg Count=3Arguments are=C:\tmp\a.exe,11111,127.0.0.1HELLOWORLDSTARTport num=11111IP ADDR=127.0.0.1END/* some algorithm of calculation */code that was not posted.