Quantcast
Channel: sizeof operator returns different values for c & c++? - Stack Overflow
Browsing latest articles
Browse All 3 View Live

Answer by Adam Maras for sizeof operator returns different values for c & c++?

Because in C++, the struct you defined is named S, while in C, it's named struct S (which is why you often see typedef struct used in C code). If you were to change the code to the following, you would...

View Article



Answer by Oliver Charlesworth for sizeof operator returns different values...

In C, to refer to the struct type, you need to say struct S. Therefore, sizeof(S) refers to the array.In C++, struct is unnecessary. So the local S hides the global S.

View Article

sizeof operator returns different values for c & c++?

A character array is defined globally and a structure with same name is defined within a function. Why sizeof operator returns different values for c & c++ ?char S[13];void fun(){ struct S { int v;...

View Article
Browsing latest articles
Browse All 3 View Live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>