PGDCA, BCA, B-Tech, MCA, M-Tech, B.Sc computer science राजस्थान सूचना सहायक व कंप्यूटर शिक्षक विशेष नोट्स: इस अध्याय में हम Structure of a C Program: Preprocessor, main(), Functions (C प्रोग्राम की संरचना: हेडर फाइल्स, main() और निष्पादन प्रवाह) की संपूर्ण थ्योरी, मुख्य तकनीकी बिंदु, तुलनात्मक तालिका और विगत परीक्षाओं के पैटर्न पर आधारित 20 अति-महत्वपूर्ण बहुविकल्पीय प्रश्न (MCQs) विस्तृत हिंदी व अंग्रेजी व्याख्या सहित पढ़ेंगे।
Overview: A standard hosted C program is organized into six classic structural sections: Documentation Comments, Preprocessor Link Directives (#include), Symbolic Definitions (#define), Global Declarations, the mandatory main() function, and User-Defined Subprograms. Execution begins logically at main() (invoked by the C runtime startup) and flows top-down across semicolon-terminated statements until returning an exit status to the operating system.
अध्याय सार: प्रत्येक मानक (Hosted) C प्रोग्राम छह मुख्य संरचनात्मक भागों में व्यवस्थित होता है: डॉक्यूमेंटेशन कमेंट्स, प्रीप्रोसेसर लिंक डायरेक्टिव्स (#include), डेफिनिशन सेक्शन (#define), ग्लोबल डिक्लेरेशन, अनिवार्य main() फंक्शन और यूज़र-डिफाइंड सब-प्रोग्राम्स। निष्पादन तार्किक रूप से main() से शुरू होकर ; से समाप्त होने वाले कथनों के माध्यम से आगे बढ़ता है और अंत में OS को एग्जिट कोड लौटाता है।
Structure of a C Program: Preprocessor, main(), Functions: Detailed Notes & Architecture (C प्रोग्राम की संरचना: हेडर फाइल्स, main() और निष्पादन प्रवाह)
1. The Six Classic Sections of a C Program (C प्रोग्राम के छह मानक संरचनात्मक भाग)
[EN] Every complete C source module is structured cleanly into six logical zones: (1) Documentation section using /* ... */ or // comments describing author, purpose, and inputs; (2) Link section (#include <stdio.h>) pulling in library declarations; (3) Definition section (#define PI 3.14159) establishing symbolic constants; (4) Global declaration section holding file-scope variables and forward function prototypes; (5) The mandatory main() function divided into local declarations and executable statements inside braces { }; and (6) Subprogram section implementing all user-defined functions.
[HI] एक संपूर्ण C सोर्स फाइल छह स्पष्ट भागों में विभाजित होती है: (1) डॉक्यूमेंटेशन सेक्शन (कमेंट्स), (2) लिंक सेक्शन (#include हेडर फाइल्स), (3) डेफिनिशन सेक्शन (#define मैक्रोज़), (4) ग्लोबल डिक्लेरेशन व फंक्शन प्रोटोटाइप, (5) अनिवार्य main() फंक्शन (डिक्लेरेशन + निष्पादनीय भाग) और (6) यूज़र-डिफाइंड फंक्शन्स का सबप्रोग्राम सेक्शन। न्यूनतम चलने योग्य प्रोग्राम में केवल main() आवश्यक होता है।
2. Preprocessor Directives: #include < > vs " " & No Semicolons (प्रीप्रोसेसर डायरेक्टिव्स (#include, #define) और सेमीकोलन नियम)
[EN] Preprocessor lines begin with a hash (#) and execute as text transformations before the compiler parses C syntax; consequently, directives like #include and #define must NEVER end with a semicolon (;), because adding one pastes an unwanted semicolon wherever a macro expands. Angle brackets (#include <stdio.h>) instruct the preprocessor to search standard compiler/system include directories directly, whereas double quotes (#include "config.h") search the current source directory first before falling back to system paths. Header guards (#ifndef ... #define ... #endif) protect multi-file builds against duplicate declarations.
[HI] प्रीप्रोसेसर डायरेक्टिव्स # चिह्न से शुरू होते हैं और संकलन से पहले टेक्स्ट बदलाव करते हैं, इसलिए इनके अंत में कभी सेमीकोलन (;) नहीं लगाया जाता। #include <stdio.h> मानक सिस्टम डायरेक्टरी में हेडर खोजता है, जबकि #include "my.h" पहले वर्तमान प्रोजेक्ट फोल्डर में और फिर सिस्टम पथ में खोजता है। हेडर गार्ड (#ifndef/#define/#endif) डुप्लीकेट डिक्लेरेशन से बचाते हैं।
3. The main() Entry Point, Valid Signatures & CRT Startup (main() फंक्शन, मान्य सिग्नेचर और एग्जिट स्टेटस)
[EN] In a hosted OS environment, program execution logically begins at main()—even though the OS loader first invokes C Runtime (CRT) startup code (_start), which sets up stdin/stdout, parses command-line arguments, calls main(), and passes its return value to exit(). ISO C specifies exactly two valid portable signatures: int main(void) and int main(int argc, char *argv[]), where argc holds the argument count (>= 1) and argv[argc] is guaranteed NULL. Using void main() is non-standard in hosted C, and since C99 reaching the closing brace } of main() without an explicit return statement implicitly returns 0 (success).
[HI] होस्टेड वातावरण में प्रोग्राम का निष्पादन तार्किक रूप से main() से शुरू होता है (जबकि वास्तविक OS लोडर पहले CRT _start चलाकर main() को कॉल करता है)। ISO C केवल दो मानक सिग्नेचर स्वीकार करता है: int main(void) तथा int main(int argc, char *argv[])। void main() मानक-विरुद्ध है; C99+ में main() के अंत में return 0 न लिखने पर भी कंपाइलर स्वतः 0 (सफलता) लौटा देता है।
4. Function Prototypes, Case Sensitivity & Execution Flow (फंक्शन प्रोटोटाइप, केस-सेंसिटिविटी और निष्पादन प्रवाह)
[EN] Because C compilers perform single-pass top-down parsing, any user-defined function placed below main() must have a Function Prototype (e.g., double area(double r);) declared above main() so the compiler verifies argument types and return type. Inside functions, statements execute sequentially from top to bottom within { } blocks and MUST terminate with a semicolon (;). C is strictly case-sensitive (Main or MAIN will fail linking as main is missing), and standard ISO C prohibits defining a nested function inside another function body.
[HI] C कंपाइलर ऊपर से नीचे (Top-Down) कोड पढ़ता है, इसलिए यदि यूज़र फंक्शन main() के नीचे लिखा गया है तो उसके ऊपर फंक्शन प्रोटोटाइप देना आवश्यक होता है। ब्लॉक { } के भीतर प्रत्येक कथन ; (Statement Terminator) से समाप्त होता है। C केस-सेंसिटिव है (Main और main अलग हैं) तथा मानक ISO C किसी फंक्शन के अंदर दूसरा फंक्शन परिभाषित करने की अनुमति नहीं देता।
Syntax, Formula & Technical Example (Structure of a C Program: Preprocessor, main(), Functions)
/* 1. Documentation: Circle Area Program */
#include <stdio.h> /* 2. Link Section */
#define PI 3.14159 /* 3. Definition Section */
double circle_area(double r); /* 4. Global Prototype */
int main(void) { /* 5. Mandatory main() Entry */
double radius = 5.0;
printf("Area = %.2f\n", circle_area(radius));
return 0; /* Exit code 0 to OS */
}
double circle_area(double r) { /* 6. User-Defined Subprogram */
return PI * r * r;
}
Structure of a C Program: Preprocessor, main(), Functions Quick Reference & Comparison Table
| Program Section | Syntax / Construct Used | Compiler Rule & Exam Fact |
|---|---|---|
| Documentation Section | /* multi-line */ or // single-line comments | Removed by preprocessor; comments cannot nest in /* */ |
| Link & Definition | #include <header.h> and #define NAME val | No trailing semicolon; < > checks system path, " " local first |
| Global Declaration | File-scope variables & function prototypes | Required above main() if subprograms sit below main() |
| main() & Subprograms | int main(void) / int main(int argc, char *argv[]) | Mandatory entry point; returns 0 (EXIT_SUCCESS) to OS |
Structure of a C Program: Preprocessor, main(), Functions Top 20 Bilingual MCQs with Answers
Q1. Which single structural component is strictly mandatory in every executable hosted C program?
(प्रत्येक निष्पादनीय (Hosted) C प्रोग्राम में कौन सा एक भाग अनिवार्य रूप से होना ही चाहिए?)
(A) Global variables
(B) The main() function
(C) #define macro constants
(D) User-defined subprogram functions besides main()
Correct Answer: (B)
[EN] A minimal valid C program like 'int main(void) { return 0; }' requires no globals, macros, or extra headers—only main().
[HI] एक न्यूनतम मान्य C प्रोग्राम बिना #define, ग्लोबल वेरिएबल या अतिरिक्त फंक्शन के भी चल सकता है, परंतु main() होना अनिवार्य है।
Q2. Why should a semicolon (;) NEVER be placed at the end of #define PI 3.14 or #include <stdio.h>?
(#define PI 3.14 या #include <stdio.h> के अंत में सेमीकोलन (;) क्यों नहीं लगाया जाता?)
(A) Preprocessor directives are text commands, not C statements; a trailing ; in #define gets pasted into expressions and causes syntax errors
(B) ANSI C uses colons : for preprocessor lines
(C) The preprocessor automatically strips every semicolon in the file
(D) Semicolons make headers execute twice faster
Correct Answer: (A)
[EN] Writing '#define PI 3.14;' turns 'area = PI * r;' into 'area = 3.14; * r;', triggering an immediate compiler error.
[HI] प्रीप्रोसेसर डायरेक्टिव्स C स्टेटमेंट नहीं हैं; #define PI 3.14; लिखने पर मैक्रो विस्तार के साथ ; भी चिपक कर सिंटैक्स एरर दे देगा।
Q3. How does #include "utils.h" differ from #include <stdio.h> during preprocessing?
(प्रीप्रोसेसिंग के दौरान #include "utils.h" और #include <stdio.h> में क्या अंतर है?)
(A) Angle brackets only work in C++ and fail in C
(B) Double quotes include binary .exe files while < > include text
(C) There is zero difference in search order
(D) Double quotes search the current source file's directory first before standard system paths; angle brackets search system include paths directly
Correct Answer: (D)
[EN] Project-local headers use quotes (" ") so your local file takes priority, whereas standard library headers use < >.
[HI] डबल कोट्स (" ") पहले प्रोजेक्ट की वर्तमान डायरेक्टरी में हेडर खोजते हैं, जबकि एंगल ब्रैकेट (< >) सीधे सिस्टम की मानक डायरेक्टरी में खोजते हैं।
Q4. Which two signatures of main() are explicitly guaranteed portable by the ISO C standard for hosted programs?
(होस्टेड प्रोग्राम्स के लिए ISO C मानक द्वारा main() के कौन से दो सिग्नेचर आधिकारिक रूप से मान्य माने गए हैं?)
(A) int main(void) and int main(int argc, char *argv[])
(B) void main() and float main(void)
(C) char main(int x) and int MAIN()
(D) static void main(string args)
Correct Answer: (A)
[EN] ISO C requires main to return int to communicate exit status to the OS; void main() is non-standard and may pass garbage exit codes.
[HI] ISO C के अनुसार main() को OS को स्टेटस लौटाने हेतु int रिटर्न करना चाहिए: int main(void) और int main(int argc, char *argv[])।
Q5. In int main(int argc, char *argv[]), what does argv[0] normally store and what is guaranteed about argv[argc]?
(int main(int argc, char *argv[]) में argv[0] सामान्यतः क्या रखता है और argv[argc] के बारे में क्या गारंटी है?)
(A) argv[0] holds the first user argument and argv[argc] equals argc
(B) argv[0] holds the OS kernel version and argv[argc] is uninitialized garbage
(C) argv[0] is always NULL
(D) argv[0] holds the program invocation name, and argv[argc] is guaranteed to be a NULL pointer
Correct Answer: (D)
[EN] Command-line arguments reside in argv[1] through argv[argc-1], preceded by the program name at argv[0] and terminated by NULL at argv[argc].
[HI] argv[0] में प्रोग्राम का नाम, argv[1..argc-1] में कमांड-लाइन तर्क और argv[argc] पर सदैव NULL पॉइंटर होता है।
Q6. What does returning 0 from main() communicate to the host operating system?
(main() से 0 (return 0;) लौटाने का होस्ट ऑपरेटिंग सिस्टम के लिए क्या अर्थ होता है?)
(A) Infinite loop continuation
(B) Memory allocation failure
(C) Compilation warning count
(D) Normal, successful program termination (EXIT_SUCCESS)
Correct Answer: (D)
[EN] By POSIX and C convention (<stdlib.h> EXIT_SUCCESS = 0), exit code 0 signals success while non-zero values indicate error conditions.
[HI] मानक परंपरा में एग्जिट कोड 0 (EXIT_SUCCESS) प्रोग्राम की सफल समाप्ति और गैर-शून्य मान किसी त्रुटि को दर्शाता है।
Q7. In modern ISO C (C99 and later), what happens if execution reaches the closing brace } of int main(void) without an explicit return statement?
(आधुनिक ISO C (C99 या बाद) में यदि int main(void) बिना return स्टेटमेंट के अंतिम } तक पहुँच जाए तो क्या होता है?)
(A) It restarts main() from the top indefinitely
(B) It causes a fatal compiler syntax error everywhere
(C) It implicitly acts as if 'return 0;' were executed
(D) It implicitly returns -1
Correct Answer: (C)
[EN] C99 standardized implicit 'return 0;' specifically for main() (not for other non-void functions!).
[HI] C99 ने विशेष रूप से main() फंक्शन के लिए यह नियम बनाया कि अंत में return न होने पर स्वतः 0 मान लिया जाए।
Q8. What role does the semicolon (;) play inside the body of a C function?
(किसी C फंक्शन के भीतर सेमीकोलन (;) की क्या भूमिका होती है?)
(A) It separates statements only when two appear on one line
(B) It terminates compound { } function bodies
(C) It marks the start of a multi-line comment
(D) It acts as a mandatory statement terminator ending each simple statement
Correct Answer: (D)
[EN] Unlike Pascal (separator), C treats ';' as a terminator required after declarations, expressions, and return statements (not after } of functions).
[HI] C में सेमीकोलन प्रत्येक सामान्य कथन को समाप्त करने वाला Statement Terminator है; फंक्शन या ब्लॉक के } के बाद इसकी आवश्यकता नहीं होती।
Q9. Suppose a user defines 'int helper(int x)' AFTER main() in a .c file without writing a prototype before main(). What happens in ISO C99+?
(यदि कोई प्रोग्रामर main() के बाद 'int helper(int x)' परिभाषित करे और main() के ऊपर उसका प्रोटोटाइप न दे, तो C99+ में क्या होगा?)
(A) C executes helper() at runtime without type checks
(B) The preprocessor moves helper() above main() automatically
(C) The compiler raises an error/diagnostic because implicit function declarations were removed in C99
(D) The linker automatically reorders the file before parsing
Correct Answer: (C)
[EN] C parses top-to-bottom; without a forward prototype above the call site, C99/C11/C23 rejects undeclared functions.
[HI] C कंपाइलर ऊपर से नीचे पढ़ता है, अतः main() के नीचे बने फंक्शन को पहले कॉल करने के लिए ऊपर प्रोटोटाइप देना अनिवार्य है।
Q10. What happens if you name your entry function 'int Main(void)' instead of 'int main(void)'?
(यदि आप अपने मुख्य फंक्शन का नाम 'int main(void)' के बजाय 'int Main(void)' लिख दें तो क्या होगा?)
(A) The preprocessor converts all uppercase identifiers to lowercase
(B) Linking fails with an undefined reference to 'main' because C is strictly case-sensitive
(C) It runs normally only on Windows
(D) The compiler silently renames Main to main
Correct Answer: (B)
[EN] Because C distinguishes uppercase and lowercase letters, Main and main are completely separate identifiers.
[HI] C केस-सेंसिटिव भाषा है, इसलिए Main और main अलग माने जाएंगे और लिंकर main न मिलने की त्रुटि देगा।
Q11. In a hosted environment, which piece of code runs BEFORE main() to prepare stdio streams and arguments?
(होस्टेड वातावरण में main() से पहले कौन सा कोड चलकर stdio स्ट्रीम्स व कमांड-लाइन तर्क तैयार करता है?)
(A) The C Runtime (CRT) startup routine (e.g., _start in crt1.o)
(B) The #include preprocessor directive at runtime
(C) The BIOS bootloader directly inside main()
(D) The user's last subprogram
Correct Answer: (A)
[EN] The linker attaches CRT startup code which initializes the runtime environment, invokes main(argc, argv), and exits with its return value.
[HI] लिंकर द्वारा जोड़ा गया CRT स्टार्टअप कोड (_start) पहले पर्यावरण तैयार करता है और फिर main() को कॉल करता है।
Q12. What happens if you write nested C-style block comments: /* outer /* inner */ still comment? */
(यदि आप नेस्टेड ब्लॉक कमेंट /* outer /* inner */ outer_end */ लिखते हैं तो C कंपाइलर क्या करेगा?)
(A) The inner comment turns into a #define macro
(B) Both comments nest cleanly and get ignored
(C) Syntax error—/* ... */ comments do NOT nest, so the first */ closes the comment early
(D) The compiler treats it as a valid string literal
Correct Answer: (C)
[EN] Because /* opens a comment and the very first */ closes it immediately, 'outer_end */' is parsed as invalid C code.
[HI] C में /* ... */ कमेंट्स नेस्ट नहीं हो सकते; पहला */ मिलते ही कमेंट बंद हो जाता है और शेष टेक्स्ट सिंटैक्स एरर पैदा करता है।
Q13. Are nested function definitions (defining a function directly inside another function's braces) valid in standard ISO C?
(क्या मानक ISO C में किसी एक फंक्शन के भीतर दूसरा फंक्शन परिभाषित (Nested Function) करना वैध है?)
(A) Only inside void main()
(B) Yes — up to 8 levels of nested functions are standard
(C) Yes — ANSI C89 requires all helper functions to be nested inside main()
(D) No — ISO C forbids nested function definitions inside another function
Correct Answer: (D)
[EN] Standard C requires all functions to be defined at file scope (GCC offers nested functions only as a non-portable GNU extension).
[HI] मानक ISO C में सभी फंक्शन फाइल स्कोप पर ही परिभाषित होने चाहिए; एक फंक्शन के अंदर दूसरा फंक्शन परिभाषित करना अवैध है।
Q14. What are the standard symbolic exit status constants defined in <stdlib.h> for terminating main()?
(main() को समाप्त करने के लिए <stdlib.h> में कौन से दो मानक सिम्बॉलिक एग्जिट स्थिरांक परिभाषित हैं?)
(A) EXIT_SUCCESS and EXIT_FAILURE
(B) OK_STATUS and ERR_STATUS
(C) PASS_0 and FAIL_1
(D) TRUE_EXIT and FALSE_EXIT
Correct Answer: (A)
[EN] EXIT_SUCCESS (0) and EXIT_FAILURE (non-zero) provide portable exit indicators across POSIX, Windows, and embedded OSes.
[HI] <stdlib.h> में EXIT_SUCCESS (0) और EXIT_FAILURE (गैर-शून्य) पोर्टेबल एग्जिट कोड के रूप में परिभाषित हैं।
Q15. In the classic six-part C layout, what goes inside the 'Definition Section' right after Link directives?
(छह-भाग वाली पारंपरिक C संरचना में लिंक सेक्शन (#include) के ठीक बाद 'डेफिनिशन सेक्शन' में क्या लिखा जाता है?)
(A) The return 0; statement
(B) Local variables inside main()
(C) Implementation bodies of helper functions
(D) Symbolic constants and macro definitions using #define
Correct Answer: (D)
[EN] Constants like #define MAX_SIZE 100 are placed in the Definition section at the top so the entire file can use them.
[HI] डेफिनिशन सेक्शन में #define द्वारा सिम्बॉलिक स्थिरांक और मैक्रोज़ परिभाषित किए जाते हैं।
Q16. Which statement about the structure of a C program is FALSE?
(C प्रोग्राम की संरचना के बारे में निम्नलिखित में से कौन सा कथन असत्य (FALSE) है?)
(A) Every C program must contain at least one global variable and one user-defined subprogram besides main()
(B) Comments are stripped before the compiler parses C tokens
(C) Multiple statements may appear on the same line if separated by semicolons
(D) Compound statements are enclosed inside curly braces { }
Correct Answer: (A)
[EN] Global variables and extra subprograms are completely optional—only main() is required in a standalone hosted C program.
[HI] ग्लोबल वेरिएबल्स और अतिरिक्त सब-प्रोग्राम पूर्णतः वैकल्पिक हैं; केवल main() ही अनिवार्य है।
Q17. Within Structure of a C Program: Preprocessor, main(), Functions, which program section directly maps to: "/* multi-line */ or // single-line comments"?
(Structure of a C Program: Preprocessor, main(), Functions में कौन सा Program Section सीधे "/* multi-line */ or // single-line comments" से संबंधित है?)
(A) main() & Subprograms
(B) Global Declaration
(C) Documentation Section
(D) Link & Definition
Correct Answer: (C)
[EN] In Structure of a C Program: Preprocessor, main(), Functions, 'Documentation Section' handles '/* multi-line */ or // single-line comments' (Removed by preprocessor; comments cannot nest in /* */).
[HI] Structure of a C Program: Preprocessor, main(), Functions में 'Documentation Section' का कार्य/विवरण '/* multi-line */ or // single-line comments' (Removed by preprocessor; comments cannot nest in /* */) है।
Q18. Which option accurately describes 'Link & Definition' in Structure of a C Program: Preprocessor, main(), Functions?
(Structure of a C Program: Preprocessor, main(), Functions के संदर्भ में 'Link & Definition' की सही विशेषता कौन सी है?)
(A) File-scope variables & function prototypes
(B) #include <header.h> and #define NAME val
(C) /* multi-line */ or // single-line comments
(D) int main(void) / int main(int argc, char *argv[])
Correct Answer: (B)
[EN] 'Link & Definition' provides '#include <header.h> and #define NAME val' — key point: No trailing semicolon; < > checks system path, " " local first.
[HI] 'Link & Definition' का मुख्य विवरण '#include <header.h> and #define NAME val' है (No trailing semicolon; < > checks system path, " " local first)।
Q19. In Structure of a C Program: Preprocessor, main(), Functions, identify the correct parameter for the specification: "File-scope variables & function prototypes".
(Structure of a C Program: Preprocessor, main(), Functions में "File-scope variables & function prototypes" विवरण किस विकल्प के लिए सही है?)
(A) main() & Subprograms
(B) Link & Definition
(C) Documentation Section
(D) Global Declaration
Correct Answer: (D)
[EN] 'Global Declaration' corresponds to 'File-scope variables & function prototypes' (Required above main() if subprograms sit below main()).
[HI] 'Global Declaration' का संबंध 'File-scope variables & function prototypes' (Required above main() if subprograms sit below main()) से है।
Q20. Considering Structure of a C Program: Preprocessor, main(), Functions, what key behavior defines 'main() & Subprograms'?
(Structure of a C Program: Preprocessor, main(), Functions में 'main() & Subprograms' की मुख्य भूमिका या मान क्या है?)
(A) int main(void) / int main(int argc, char *argv[])
(B) /* multi-line */ or // single-line comments
(C) File-scope variables & function prototypes
(D) #include <header.h> and #define NAME val
Correct Answer: (A)
[EN] 'main() & Subprograms' represents 'int main(void) / int main(int argc, char *argv[])' (Mandatory entry point; returns 0 (EXIT_SUCCESS) to OS).
[HI] 'main() & Subprograms' का अर्थ/मान 'int main(void) / int main(int argc, char *argv[])' है (Mandatory entry point; returns 0 (EXIT_SUCCESS) to OS)।
Structure of a C Program: Preprocessor, main(), Functions — Exam FAQs
Q1: Why do older Turbo C tutorials teach void main(), whereas modern compilers warn against it?
पुरानी Turbo C किताबें void main() क्यों सिखाती थीं, जबकि आधुनिक कंपाइलर चेतावनी देते हैं?
[EN] Turbo C predated strict standard enforcement and ignored exit codes under single-task MS-DOS. Under modern OSes (Windows, Linux), scripts and shells check main()'s int return value; void main() violates ISO C for hosted environments.
[HI] Turbo C पुराने 16-बिट DOS युग का था। आधुनिक ऑपरेटिंग सिस्टम्स में शेल प्रोग्राम के int एग्जिट कोड की जांच करते हैं, और ISO C में hosted प्रोग्राम के लिए int main(...) ही मानक है।
Q2: Can a C program ever run without a main() function?
क्या कोई C प्रोग्राम बिना main() फंक्शन के भी चल सकता है?
[EN] Not in standard hosted C—the linker looks for main. Only in special freestanding environments (kernels/bootloaders using -ffreestanding -nostdlib) or deceptive #define macros like '#define start main' can the literal word 'main' be avoided.
[HI] सामान्य होस्टेड C में बिना main() के लिंकिंग विफल हो जाती है; केवल कर्नेल/बूटलोडर जैसे freestanding मोड (-nostdlib) या #define चाल से ही यह अपवाद संभव है।
Q3: Why can you place declarations anywhere inside a block in C99+, whereas C89 forced them at the top?
C99 और बाद के मानकों में ब्लॉक के बीच में वेरिएबल डिक्लेयर क्यों कर सकते हैं, जबकि C89 में यह केवल सबसे ऊपर संभव था?
[EN] C89 required all local declarations before the first executable statement of a { } block to simplify one-pass stack allocation; C99 relaxed this rule so variables can be declared right where first needed.
[HI] C89 में स्टैक आवंटन सरल रखने हेतु ब्लॉक की शुरुआत में ही सभी डिक्लेरेशन लिखने होते थे, जिसे C99 ने हटाकर कोड के बीच में डिक्लेरेशन की अनुमति दे दी।
Post a Comment
Post a Comment