3
What’s wrong here? I can’t 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);
}
3
What’s wrong here? I can’t 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);
}
8
There are three mistakes:
main
and not Main
.int
and not void
. Some compilers accept this form but this does not mean it is correct to use in standard C./*
is a start of comment. You need to ensure that there is no ambiguity 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);
}
Behold working in the ideone. And in the repl it.. Also put on the Github for future reference.
Thanks @bigown
Doesn’t Have To Be int main
In Visual C++ 2013 Roda De Boa Como void
.
@axell13 I edited to clarify this point
Instead of parentheses to avoid ambiguity, you can also use white space (white space is cheap and makes code more readable): c = a / *p;
Browser other questions tagged c syntax
You are not signed in. Login or sign up in order to post.
At these times it always helps to show which error message is returned by the compiler.
– hugomg
truth @hugomg
– drd0sPy
@drd0sPy So you don’t want [Edit] the question to include the error message as hugomg suggested?
– bfavaretto