Hi.
I know that the problem is about C programming.
I have created an application that requires as input some parameters from
command line. After this my application do some computations and print
those parameters as fallow:
int main(int argc, char* argv[])
{
fprintf(stdout,"%s %s",argv[1],argv[2]); //print the value from
input
//some computations
return 0;
}
Why are the parameters shown in the final ? I need those parameters in
computations block.
Thanks
C printf shows result at the end
I didn't understand what do you wanna...
but i hope it helps you.
int main(int argc, char** argv) {
if (argc >= 2) {
int a = atoi(argv[1]);
int b = atoi(argv[2]);
fprintf(stdout,"Param1 - %s Param2 - %s\n",argv[1],argv[2]);
/* computation block */
int computationResult = a + b;
/* end of computation block */
fprintf(stdout,"Computation result - %d\n",computationResult);
} else {
printf("Not enough parameters\n");
}
return 0;
}
Your question was not clear to me, but i think you are facing a buffered i/o problem. add a \n, so the system will send out the line. fprintf(stdout,"%s %s\n",argv[1],argv[2]); or if you dont want a new line fprintf(stdout,"%s %s",argv[1],argv[2]); fflush(stdout); cheers, hex


