December 26, 2022

C v/s C++

Posted on December 26, 2022  •  2 minutes  • 276 words

1. File Extension:

  1. C - Files are saved with .c extension.
  2. C++ - Files are saved with .cpp extension.

2. Area of usage:

  1. C - Embedded devices And system-level code.
  2. C++ - Gaming,networking and server-side applications.

3. Compatibility:

  1. C - The C compiler isn’t able to execute the C++ code.
  2. C++ - C++ is a superset of C so C++ is able to run most C code.

4. OOP - Compatibility:

  1. C - It does not Support Object-Oriented -Programming (OOP)
  2. C++ - It Support Object-Oriented -Programming (OOP)

for more visit Class and Objects in C++

5. Exception Handling:

  1. C - It does not Support Exception Handling
  2. C++ - It Support Exception Handling

6. Use of Strings :

  1. C - The char[] represents string literals in C.
  2. C++ has a variable type called string.

for more visit C++ String snd Boolean

7. Default Header File:

  1. C - stdio.h
#include <stdio.h>
  1. C++ - iostream.h
#include <iostream>

for more visit Create Header Files

8. Functions with Default Arguments:

  1. C - It does not allow Using functions with default arguments.
  2. 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:

  1. C - It has GTK tool for enabling GUI programming.
  2. C++ - It has QT tool for enabling GUI programming.

10. Input and Output Functions:

  1. C - It uses scanf() and printf() for input and output operations.
  2. C++ - It uses cin and cout for input and output operations.

for more visit C++ Input and Output Functions

Follow me

I work on everything coding and share developer memes