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 714817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:07:02+00:00 2026-05-14T05:07:02+00:00

In the interpreter for my programming languages I have to correctly handle the parts

  • 0

In the interpreter for my programming languages I have to correctly handle the parts in case the import function is called. I then need to check if such a file is in the /libs folder (located at the same place as my executeable!) and if it doesn’t exist I have to check in the directory of the current script.

  • How can I get the exact path to the directory where the executeable is located from argv?
  • What is the best way to remove the file from the end of a path, e.g:

    C:/a/b/c/file.exe should become C:/a/b/c/

  • 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-14T05:07:03+00:00Added an answer on May 14, 2026 at 5:07 am
    1. There is no guaranteed way to do that. You can try looking in argv[0] but whether that has the full path or just the name of the binary depends on the platform and how your process was invoked.
    2. You can use strrchr to find the last slash and replace the character after it with '\0'

    Code example:

    // Duplicate the string so as not to trash the original
    // You can skip this if you don't mind modifying the original data
    // and the originald is writeable (i.e. no literal strings)
    char *path = strdup(...);
    
    char *last_slash = strrchr(path, '/');
    if (last_slash)
    {
    #if PRESERVE_LAST_SLASH
        *(last_slash + 1) = '\0';
    #else
        *last_slash = '\0';
    #endif
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently working on the topic of programming-languages and interpreter-design. I have already created
In the interpreter for my experimental programming language I have a symbol table. Each
In interpreted programming languages, such as PHP and JavaScript, what are the repercussions of
In all programming languages supporting optional parameters that I have seen there is a
I'm learning OCaml and although I have years of experience with imperative programming languages
I have a thread datatype in the interpreter implementation for a programming language I
I'm programming an interpreter for an experimental programming language (educational, fun,...) So far, everything
I've created an interpreter for a stupid programming language in C++ and the whole
There are a bunch of different Scheme interpreters available for the Mac: http://www.dmoz.org/Computers/Programming/Languages/Lisp/Scheme/Implementations/ Which
Are there any extensible interpreted programming languages written in standard, platform-independent C or C++?

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.