ANSI C/C++


Definition of ANSI C/C++ in Network Encyclopedia.

What is ANSI C/C++

ANSI C/C++ is a standard published by the American National Standards Institute (ANSI) for writing C and C++ code. Programs written in ANSI C or ANSI C++ are portable to a large number of computing platforms.

Most commercial C/C++ programming tools, such as Microsoft Visual C++, contain extensions to ANSI C/C++ that simplify common programming tasks considerably but restrict the portability of the resulting code to different platforms.

ANSI C++ an ANS C differences
ANSI C++ an ANS C differences

You can use Visual C++ to write strict ANSI C/C++ code by following these guidelines:

  • Call Win32 application programming interfaces (APIs) directly in your program instead of using the Microsoft Foundation Classes (MFC) libraries.
  • Disable the Microsoft extensions to C++ by running Visual C++ using the /Za command-line option.
  • Use the isostream and standard template libraries from the ANSI Standard C++ library and the appropriate #include statements in your code.

Differences between ANSI C and ANSI C++

C++ is sometimes called a multi-paradigm language, meaning it supports
many styles of programming, including object-orientated (although no two
people ever agree on what that means), procedural, and others.

C can support inheritance, polymorphism and even data encapsulation, but the language was not designed with these features in mind. The constructs needed to support those features are more difficult to implement in C than in C++.

  • C doesn’t have access to the iostream library.
  • Input and output in C is done using the stdio.h library which provides access to the scanf() and printf() functions, used to do input and output respectively.
  • C doesn’t support exception handling.
  • C doesn’t support templates.
  • C doesn’t support namespaces.
  • C doesn’t support references.
  • C doesn’t support default parameter values.
  • C doesn’t support overloaded function names.
  • C doesn’t support the four C++ cast operators static_cast,
    dynamic_cast, const_cast and reinterpret_cast. All casts must be done
    using the “C-style” cast operator.

Editor

Articles posted after being checked by editors.

Recent Posts