Program does not compile with miscellaneous errors

3

What is wrong here? I can not see the error.

#include <stdio.h>

void Main(void)
{
    int a = 9;
    int b = 3;
    int c = 0;

    int *p = &b;
    c = a/*p;

    printf("%d \n", c);


}
    
asked by anonymous 08.12.2014 / 15:11

1 answer

8

There are three errors:

  • The main function should call main and not Main .
  • This function should return a int and not void . Some compilers accept this form but this does not mean that it is correct to use in standard C.
  • The use of /* is a start of comment. You need to ensure that it is unambiguous using parentheses.

Correct code:

#include <stdio.h>

int main(void) {
    int a = 9;
    int b = 3;
    int *p = &b;
    int c = a / (*p);
    printf("%d \n", c);
}

See running on ideone . And no Coding Ground . Also put it in GitHub for future reference .

    
08.12.2014 / 15:19