In C, data type of character constants is int, but in C++, data type of same is char.
If we save below program as test.c then we get 4 as output (assuming size of integer is 4 bytes) and if we save the same program as test.cpp then we get 1(assuming size of char is 1 byte)
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Constants vs Variables in C language
- Constants in C/C++
- Difference between Type Casting and Type Conversion
- Type difference of character literals in C and C++
- Check input character is alphabet, digit or special character
- Data Type Ranges and their macros in C++
- Conversion of Struct data type to Hex String and vice versa
- Comparison of boolean data type in C++ and Java
- Is there any need of "long" data type in C and C++?
- Data type of case labels of switch statement in C++?
- Bool data type in C++
- C++ set for user define data type
- What is the size_t data type in C?
- C++ map having key as a user define data type
- What is data type of FILE in C ?
- Multi-set for user defined data type
- Difference between fundamental data types and derived data types
- What is return type of getchar(), fgetc() and getc() ?
- Function overloading and return type
- Catch block and type conversion in C++