>This will work in C++ wht abt c?
No, it won't work in either because you can't call a function at global scope. It also fails to meet the requirements because you try to use printf. :icon_rolleyes:
>HOW sizeof() implemented in C means Sourrce code?
You can't do it portably. That's why C has a sizeof operator.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
Can you use putchar() and display each character one at a time?
Aia
Nearly a Posting Maven
2,392 posts since Dec 2006
Reputation Points: 2,224
Solved Threads: 218
jbennet
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,826
Solved Threads: 601
>This will work in C++ wht abt c?
No, it won't work in either because you can't call a function at global scope....
calling a function at global scope is certainly possible in C++. dynamic initialization of statics at global scope is supported; here caling printf to initialize a global integer is no different from calling the constructor to initialize std::cout.
if you cannot use formatted output functions like printf, fprintf etc., an fwrite (unformatted output) is a possibility. fwrite returns a size_t, so you can still use it for dynamic initialization of a global int.
vijayan121
Posting Virtuoso
1,606 posts since Dec 2006
Reputation Points: 1,159
Solved Threads: 287