Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

New to C programming


ghost's Avatar
0 0

i'm a starter in 'c' language..

when i compile this programme it produces error

#inlude<stdio.h>

int main() {

extern int i =2; return 0; }

Decleration syntax error.


ghost's Avatar
0 0

you spelled 'include' wrong


ghost's Avatar
0 0

Why u using the keyword extern? its not like ur importing a variable from another file.


ghost's Avatar
0 0

extern int i =2;

Decleration syntax error.

Extern Declarations Should Never Be Initialized Coz When Extern Variables Are Declared Memory Space Is Not Alloted To It.


ghost's Avatar
0 0

the extern tag is not needed, include is spelled wrong, and on some compilers int main needs an argument otherwise it cant return 0.


ghost's Avatar
0 0
#include &lt;stdio.h&gt;

int main()
{
extern int i =2;
return 0;
}

That compiles fine in Dev-C++


ghost's Avatar
0 0

Decleration syntax error.

This Error States That There Is Some Problem With The Declaration..

For The Return Statement And Even For The Include Statement , It Would Have Generated Different Error Messgs Indicting That…..

Correct Me If I'm Wrong….


ghost's Avatar
0 0

@mastergamer

Funny Thing It Compiled…The Concept Of Extern Is Wrecked…

Extern Is Used If U Want To Use A Variable Declared And Initiallized From Another File….

If That Code Compiled, What Is The Use Of Extern???


ghost's Avatar
0 0

I am also learning c/c++. It is little complicated, but when you learn it, you can do whatever you want.


Uber0n's Avatar
Member
0 0

kaksii wrote: It is little complicated, but when you learn it, you can do whatever you want.

That's the best explanation of C/C++ there is :D


ghost's Avatar
0 0

cant do EVERYTHING, thats where assembler comes in, which im learning :P lol


ghost's Avatar
0 0

I am also learning C. It is little hard, but when I learn it, it will be great