+ 1

C problem

In c language, if we declare and initialise main as a variable, shouldn't it produce a compile time error? int main=3; (It will print 3 ) why? Can anyone explain?

18th Aug 2020, 7:17 AM
Chetna Gupta
Chetna Gupta - avatar
4 Answers
+ 3
But main is inbuilt function, i thought we can't use it as a variable namešŸ¤”
18th Aug 2020, 7:36 AM
Chetna Gupta
Chetna Gupta - avatar
+ 2
`main()` is not a inbuilt function. It's a user defined function. > In c language, if we declare and initialise main as a variable, shouldn't it produce a compile time error? No. `main` is not a keyword. It's a valid identifier. Declarating a variable `main` at function scope or block scope won't generate error. If you declare `main` variable at file scope it'll generate error.
18th Aug 2020, 8:20 AM
šŸ‡®šŸ‡³OmkaršŸ•‰
šŸ‡®šŸ‡³OmkaršŸ•‰ - avatar
+ 2
Main() is not a user defined function, its a predefined function
18th Aug 2020, 8:23 AM
Chetna Gupta
Chetna Gupta - avatar
+ 1
Ok...thanks
18th Aug 2020, 7:55 AM
Chetna Gupta
Chetna Gupta - avatar