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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:31:15+00:00 2026-05-18T06:31:15+00:00

The problem is the variable nodeType is being changed after STRCPY finishes running. nodeType

  • 0

The problem is the variable nodeType is being changed after STRCPY finishes running. nodeType is not a variable that is related to any of the other variables being used in the STRCPY call. It is in the same struct though. nodeType is a enum with the int value of 3.

Below if the following information that is probably most relevant. I removed most of the variables from the enum and struct so they aren’t visible, I assume they aren’t relevant to the problem. I am coding in VS2010 if that makes a difference. This is part of an assignment to create a btree, but the question I have has nothing to do with btrees.

enum NODETYPE
{ 
  ROOTLEAF
};
typedef struct node
{
  char key[MAX_CHILDREN_ROOT][MAX_KEY_LENGTH];
  NODETYPE nodeType;
} nodeT;

… part of the insertElement function

for (int i = 0; i < (b->tempNode->numberOfKeys - b->searchData.position); i++)
{
  strcpy(b->tempNode->key[b->tempNode->numberOfKeys - i],  b->tempNode->key[b->tempNode->numberOfKeys - (i + 1)]);
}

.. the function I called was the to insert an element. I have called the function several times prior to this but this is the first this section of code below is being run. After STRCPY runs nodeType takes the value 1280070990. I set the variable to watch and while its in CXX0017 error, which I assume only means its not in scope.

I looked up the number 1280070990 which spawned a bunch of game related issues from various engines. I’d guess its a memory address problem.

Solution was a provided below. It was a simple error of writing outside of the array boundary. I broke the old code down like this and then walked through it. This allowed me to identify the problem which was me writing outside of the key array key.

        for (int i = 0; i < (b->tempNode->numberOfKeys - b->searchData.position); i++)
    {
        int sourceI = b->tempNode->numberOfKeys - i - 2;
        int destI = b->tempNode->numberOfKeys - i - 1;
        char *Source = b->tempNode->key[sourceI];
        char *Dest = b->tempNode->key[destI];
        strcpy(Dest, Source);
    }

A full look at the struct that both variables were in.

typedef struct node
{
    node *childrenPTR[MAX_CHILDREN_ROOT]; 
    int depth; //Distance from root to node
    char key[MAX_CHILDREN_ROOT][MAX_KEY_LENGTH];
    NODETYPE nodeType;
    int numberOfChildren;
    int numberOfKeys;
    node *parentPTR;
} nodeT;

We can see from the order of the variables in the struct that nodeType follows key. I believe C will allocate the memory in this same order. So I could of looked here as well to identify the problem.

  • 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-18T06:31:15+00:00Added an answer on May 18, 2026 at 6:31 am

    You’re copying a string that’s too long into key[] somewhere. It’s overflowing into nodeType.

    Since I’m guessing you’re new at this, I’d re-code this for a bit easier reading for you to get a handle on what’s going on. Perhaps something like:

    for (int i = 0; i < (b->tempNode->numberOfKeys - b->searchData.position); i++)
    {
      char *dest = b->tempNode->key[b->tempNode->numberOfKeys - i];
      char *source = b->tempNode->key[b->tempNode->numberOfKeys - (i + 1)];
      strcpy(dest, source);
    }
    

    Walk that through a debugger and source will probably be longer than (with the null terminator — you are null terminating your strings right?) MAX_KEY_LENGTH somewhere in your array. It might even be something crazy not even in your array.

    Break it down into something smaller and easier to debug in discreet steps.

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

Sidebar

Related Questions

I have problem with variable printing inside javascript. variable htmlString printing not working: document.write(htmlString)
I defined a global variable that is called from other view and it is
How do I get past this variable initialization problem? If I only could figure
I am having a problem setting the Authorize attribute Role value from a variable.
I'm facing a real problem in understanding how to draw a variable diagram to
I've just encountered a weird problem, I'm trying to printf an integer variable, but
Is it a problem if you use the global keyword on variables you don't
Problem: I have two spreadsheets that each serve different purposes but contain one particular
Problem (simplified to make things clearer): 1. there is one statically-linked static.lib that has
Problem: Ajax suggest-search on [ n ] ingredients in recipes. That is: match recipes

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.