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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:07:59+00:00 2026-05-30T13:07:59+00:00

I have these variables set in my debugger: //Debugger values not code relative_path =

  • 0

I have these variables set in my debugger:

//Debugger values not code

relative_path = “./bin/Debug”

strlen(relative_path)=11

relative_path[11] = 0 ‘\000’ //As shown in Eclipse debugger

In my code I then do:

//**My Code**
struct dirs_later {
    const char *findme;
    struct dirent *dptr;
    struct stat this_lstat;
    char *relative_path;
    const char *type_str;
    DIR * dir;
};

....
struct dirs_later *new_dir = malloc(sizeof(struct dirs_later*));
...
char *relative_path2 = strdup(relative_path);
if (NULL != new_dir) {
    new_dir->findme = findme;
    new_dir->dptr = dptr;
    new_dir->this_lstat = *this_lstat;
    new_dir->relative_path = relative_path2;
     new_dir->type_str = type_str;
    }

but then the debugger shows after new_dir->relative_path = relative_path2. Then in the debugger:

//Debugger values not code

relative_path2 = “&\275\001” and

strlen(relative_path2) =3

I also tried this in my code instead:

//**My Code**
char *relative_path2 = malloc(strlen(relative_path) + 1 * sizeof(char));
//check for NULL
strcpy(relative_path2, relative_path);

and I get the same result

  • 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-30T13:08:00+00:00Added an answer on May 30, 2026 at 1:08 pm

    Should the line

    struct dirs_later *new_dir = malloc(sizeof(struct dirs_later*)); 
    

    be

    struct dirs_later *new_dir = malloc(sizeof(struct dirs_later)); 
    

    as you want to create the space on the heap for the structure, not just a pointer.

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

Sidebar

Related Questions

I have certain PHP class methods that access external variables. These variables are not
I have these variables that are set in one php file, and when i
I have a number of variables which are set and later in my code
I have these two functions (with Point2D & LineVector (has 2 Point2D member variables)
If I define these variables: double x0, xn, h; int n; and I have
I have created HTTP handlers. How do I create global variables for these handlers
I have a separate file where I include variables with thier set value. How
I have an <iframe> that uses some variables that are set in an object
I have a program, and in that program there is some variables (username and
Is there anything similar to global variable in SSIS? I have 4 variables (FromAddress,

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.