Linux C + + gets file absolute path

Source: Internet
Author: User

The FTP service needs to get the absolute path of the file, here is a record.

1#include <stdlib.h>2#include <stdio.h>3#include <limits.h>4 5 intMain () {6     Const Char*file_name ="filename";7     CharAbs_path_buff[path_max];8 9     //get file path, populate to Abs_path_buffTen     //the Realpath function returns: null indicates that the acquisition failed; otherwise a pointer to Abs_path_buff is returned One     if(Realpath (file_name, Abs_path_buff)) { Aprintf"%s%s\n", file_name, abs_path_buff); -     } -     Else{ theprintf"The file '%s ' is not exist\n", file_name);  -     } -  -     return 0; +}

Linux C + + gets file absolute path

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.