Search code examples
csdcc

Simple C programs returns too many parameters error


So I'm just starting to learn C, and after setting up CodeBlocks with the SmallDevice C compiler I began working on some of the programs in the book I'm learning through. it keeps returning this error. Here is the code:

#include <stdio.h>
int main()
{
    int num1, num2, sum;
    printf("Enter two integers: \n");
    scanf("%d %d",&num1,&num2);
    sum=num1+num2;
    printf("Sum: %d",sum);
    return(0);
}

The error it's giving me is

Warning 112: Function 'scanf' implicit declaration
error 101: too many parameters

I went and found a text written up to do the exact same (which gave me the exact same code) and when I placed it in it still gives me this error. Is this a problem with my compiler?


Solution

  • Yes, it's a problem with your compiler or/and your installation. The code has no syntax errors.

    gsamaras@pythagoras:~$ pico Justc25_main.c
    gsamaras@pythagoras:~$ gcc Justc25_main.c
    gsamaras@pythagoras:~$ 
    

    As Werner Henze stated: "It looks like Small Device C compiler is for small embedded devices and does not come with scanf function.".