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

  • Home
  • SEARCH
  • 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 5942003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:11:25+00:00 2026-05-22T16:11:25+00:00

I am passing a C Macro to a function which receives it as char

  • 0

I am passing a C Macro to a function which receives it as char *. Without any reason the last character from macro gets truncated. I doubt some memory leak, but could not find where.

#define FROM "/some/local/path/from/"
#define TO "/some/local/path/to/"
....
char file[_D_NAME_MAX + 1] = {'\0'};
....
funMove(file, FROM, TO);
....
....
int funMove(char *file, char *from, char *to) {
//here the to value is one character less (/some/local/path/to) slash got truncated
}
  • 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-22T16:11:25+00:00Added an answer on May 22, 2026 at 4:11 pm

    Apologies!! Actually, nothing was wrong with the code and the macro didn’t get truncated but got overridden. There was another macro with the same name and content except the slash. So, the macro was got replaced instead of the intended one.

    #define TO "/some/local/path/to" //header file 1
    #define TO "/some/local/path/to/" //header file 2
    

    I just had the header file 2 in mind and misunderstood that the macro got truncated. Actually, the macro from header file 1 was used instead of file 2 which was the intended one.

    Thanks for all your answers and support.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have declared QOBJECT macro but still its calling the function without passing the
I know it is a Macro we are passing to a function. How do
Just started working on a c project. Need help with passing function pointers/macro functions/etc.
I'm having a macro like this ( not exactly, but function is quite equivalent):
As I understand it, when passing an object to a function that's larger than
I am using C# interop to call a macro from C#. This works fine.
I have to use a macro multiple times inside a function and the macro
I'm trying to generate a function declaration using a macro /* goal: generate int
I am trying to create an excel macro which is probably going to end
I have some code which use 'this' pointer of class which calls this code.

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.