ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1000. A+B Problem

Why this doesn't work in C GNU/Linux GCC compiler
Posted by atklin_aaron 24 Apr 2008 21:15
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
Posted by Alias aka Alexander Prudaev 25 Apr 2008 09:19
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;
}