C v/s C++
Posted on December 26, 2022 • 2 minutes • 276 words
1. File Extension:
- C - Files are saved with .c extension.
- C++ - Files are saved with .cpp extension.
2. Area of usage:
- C - Embedded devices And system-level code.
- C++ - Gaming,networking and server-side applications.
3. Compatibility:
- C - The C compiler isn’t able to execute the C++ code.
- C++ - C++ is a superset of C so C++ is able to run most C code.
4. OOP - Compatibility:
- C - It does not Support Object-Oriented -Programming (OOP)
- C++ - It Support Object-Oriented -Programming (OOP)
for more visit Class and Objects in C++
5. Exception Handling:
- C - It does not Support Exception Handling
- C++ - It Support Exception Handling
6. Use of Strings :
- C - The char[] represents string literals in C.
- C++ has a variable type called string.
for more visit C++ String snd Boolean
7. Default Header File:
- C - stdio.h
#include <stdio.h>
- C++ - iostream.h
#include <iostream>
for more visit Create Header Files
8. Functions with Default Arguments:
- C - It does not allow Using functions with default arguments.
- C++ - Allows using functions with default arguments.
#include <iostream>
void printName(std::string name="ANOOP")
{
std::cout << "Your name is " << name << std::endl;
}
int main()
{
printName("VINEETH");
printName();
}
/* Output
Your name is VINEETH
Your name is ANOOP
*/
9. GUI Programming:
- C - It has GTK tool for enabling GUI programming.
- C++ - It has QT tool for enabling GUI programming.
10. Input and Output Functions:
- C - It uses scanf() and printf() for input and output operations.
- C++ - It uses cin and cout for input and output operations.
for more visit C++ Input and Output Functions