How to use the write() system call in C++? : <p>I am a beginner in C++ and I want to know how to use the write() system call in C++ instead of using cout for my success and error messages.</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;stdio.h&gt;
using namespace std;

int rename(const char *oldpath, const char *newpath);

int main()
{
  int result;
  char oldpath[] = "oldfile.cpp";
  char newpath[] = "newfile.cpp";
  result = rename(oldpath, newpath);

  if (result == 0)
    {
      cout &lt;&lt; "File renamed successfully\n";
    }
 else
    {
      cout &lt;&lt; "Error renaming the file\n";
    }
  return 0;
}
</code></pre>
