Linux file Management (C language library function II)

Source: Internet
Author: User

file deletion and renaming int Remove (constChar *pathname); int rename (constchar *oldpath,constChar *NewPath); The Remove function removes the file name that pathname points to rename the function modifies the filename execution to return 0 successfully, the failure returns 1, and the error code is saved in the variable errno.

//Remove () function and rename ()#include <stdio.h>#include<stdlib.h>#include<string.h>#include<errno.h>intMainintArgChar*args[]) {    if(Arg <1) {printf ("Please enter a parameter! \ n"); return 0; }    //Rename File//int eno=rename (args[1],args[2]); //Remove File    /*the Remove () function header file is stdio.h*/    intEno=remove (args[1]); if(Eno = =-1) {printf ("Error msg:%s\n", Strerror (errno)); return 0; }    return 0;}

Linux file Management (C language library function II)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.