Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7667505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:07:15+00:00 2026-05-31T15:07:15+00:00

Here i used below in code on linux. using cp command in system function.

  • 0

Here i used below in code on linux.
using cp command in system function.

I know about system function it will return the 0 if command successfully executed.otherwise it will return error code.

If here i use proper source and destination path than i got output like this

Number == 0

If i give wrong source and destination path than i got

cp: cannot create regular file `/home/sam/test/test': No such file or directory
Number == 256

cp: cannot stat `/home/sam/main/test2/test': Not a directory
Number == 256

Here i want to know the error code of cp command what cp command return here.

My questions are here

1 System function return error code of cp command?
2 Can i get error code of cp command from source code of cp command?
3 i want to handle all types of error in this cp command.

code :

#include <stdlib.h>
#include <stdio.h>

void main()
{
    int a;
    a = system("cp /home/sam/main/test /home/sam");
    printf("Number == %d\n",a);
}

So any body please Explain me about this all

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:07:16+00:00Added an answer on May 31, 2026 at 3:07 pm

    The correct way to user the return value of system is with the wait-specific macros.

    if (WIFEXITED(a)) {
        int rc;
        rc = WEXITSTATUS(a);
        printf("Exit with status: %d\n", rc);
    } else {
        /* Killed by a signal. */
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here my code I used below code to calculate the distance between two location
I am trying to find if there is a system color used here, so
I am trying out WebDriverBacked selenium. I used the below code. But, it gives
i used the code below for my listview and textview . Code: textcontent.setText(Html.fromHtml(item.get_text())); textcontent.setAutoLinkMask(Linkify.WEB_URLS);
I am using below code to create three tab in activity but it gives
I displayed Image from the web. For xml I used below code: main.xml: <com.imloader.LoaderImageView
I found the below code here: How to use double buffering inside a thread
In the below code, what are all the parameters and attributes used, why are
I want to do some operation in a particular cell using some function. Here
When I am running below code in Code::Blocks in Windows OS. I used to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.