Does the system() function belong to C or C++?

#include <stdio.h> #include <stdlib.h> void main () { system("dir"); }

I have read in many C++ books where system() is used to execute command line programs. But when I tried the same command in C, it worked perfectly. So my question is whether its a standard C or C++ function? Please be liberal as I am new to C programming.


As system function is declared in stdlib.h, it can be considered a C function. But in C++, stdlib.h is merged into the std namespace and is located in the cstdlib include in this form. So the correct answer is "both".


It is both C and C++.

    <li>system : http://en.cppreference.com/w/c/program/system</li> <li>std::system: http://en.cppreference.com/w/cpp/utility/program/system</li> </ul>


    Both: it's defined by the standard C library, and the standard C++ library contains the C library.

    In C++, you should include the C++ style header, <cstdlib>, and refer to it as std::system. Including C headers directly is deprecated.


    It's both. C defines many functions. C++ defines many functions that are exactly the same as in C, some that are subtly different from how they are in C, and a lot of functions and classes that aren't part of C at all. Knowing that a function is part of standard C++ says nothing about whether it is part of standard C, and knowing that a function is part of standard C says little about whether it is part of standard C++.


    Both c and cpp support the function system as they have support for the stdlib.h that contains the prototype of system() function.


  • Conditional Counter In New Column - R
  • Can XML schema be written to allow xs:attribute of either xs:date or xs:dateTime?
  • How can convert this C# code to C++/CLI
  • Checkbox Validations
  • Need help to stop program terminating without users consent
  • PHP Handling Namespace with SimpleXML
  • Finding All Combinations (cartesian product) of list values in vb.net
  • How to add System.Windows dll to Visual Studio 2010 express?
  • C++11 variable size POD struct
  • C++ Coin flip program error
  • string.IsNullOrEmpty() Doesn't Seem to Work on a String within a Class within a Class
  • Generic/Unknown HTTP Error with response code 0 using UnityWebRequest
  • runtime-check whether an instance (Base*) override a parent function (Base::f())
  • Building Qt project for C++11 standard
  • C++ friend class std::vector
  • import scipy.sparse failed
  • WPF Template Binding in ToggleButton UserControl
  • Error in installing package: fatal error: stdlib.h: no such file or directory
  • Implicit joins and Where in Doctrine - how?
  • Differences in dis-assembled C code of GCC and Borland?
  • Android application: how to use the camera and grab the image bytes?
  • Button text different than value submitted in query string
  • Query to find the duplicates between the name and number in table
  • Eloquent update method change created_at timestamp
  • How to use carriage return with multiple line?
  • Ajax Loaded meta Tags
  • Control modification in presentation layer
  • Xamarin Forms - UWP Fonts
  • Arrow is showed instead of the material design version hamburger icon. Why doesn't syncState in
  • Adding custom controls to a full screen movie
  • How can I estimate amount of memory left with calling System.gc()?
  • Confusion with PayPal's monthly billing cycle
  • Arrays break string types in Julia
  • log4net write single file for each call to log.info
  • Exception on Android 4.0 `android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode)`
  • Checking variable from a different class in C#
  • Binding checkboxes to object values in AngularJs
  • Net Present Value in Excel for Grouped Recurring CF
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?