|
|
back to boardWhy this doesn't work in C GNU/Linux GCC compiler Why this doesn't work? #include <stdio.h> #include <stdlib.h> static int ans = 0; void add_input ( int A, int B) { ans = A + B; } int main ( int argc, char *argv[]) { int A; int B; A = atoi (argv[1]); B = atoi (argv[2]); add_input (A, B); fprintf (stdout, "%d", ans); exit (EXIT_SUCCESS); } gcc -g a_b.c -o a_b Edited by author 24.04.2008 21:15 Edited by author 24.04.2008 21:15 Re: Why this doesn't work in C GNU/Linux GCC compiler you must to read A and B from standart input, not from console parameters. int main() { int a, b; scanf("%d %d", &a, &b); printf("%d\n", a + b); return 0; } |
|
|