top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Is there a possibiliy that the same program gives different output for C and C++?

+1 vote
396 views
Is there a possibiliy that the same program gives different output for C and C++?
posted Nov 6, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Few small points

1) int new; is valid i c but int new is invalid in c++ as new is keyword in c++.
2) The C++ standard enforces that the __cplusplus macro will always be defined in C++ programs. Not the C standard obviously!
3) boolean result

printf("%d",sizeof(1==1)); // output = 4 in C (which is size of int)
cout << sizeof(1==1); // output =1 in c++ (which is the size of boolean datatype)
answer Nov 6, 2013 by Salil Agrawal
Similar Questions
+2 votes
struct marks {
  int a:1;
  int b:2;
};

int main() {
  struct marks obj={1,6};
  printf("%d %d\n",obj.b,obj.a);
}
+1 vote

Let me put some context of my curiosity -
One of the mysterious activities in Programming Language design is the aspect of standard libraries and there have been talk of "modernizing" standard libraries to meet up to the requirements:
i) Parallelism(multi-core)
ii) Searching
iii) Big data
iv) GUI lacking in C & C++
v) The top N widely used algorithms

Now as a developer I am interested to know, Is there a precise formula for the evolution of Standard Libraries and measure its effectiveness?

...