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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:54:57+00:00 2026-05-14T02:54:57+00:00

I have a C code in which I have a structure declaration which has

  • 0

I have a C code in which I have a structure declaration which has an array of int[576] declared in it.

For some reason, i had to remove this array from the structure, So I replaced this array with a pointer as int *ptr; declared some global array of same type, somewhere else in the code, and initialized this pointer by assigning the global array to this pointer. So I did not have to change the way I was accessing this array, from other parts of my code.

But it works fine/gives desired output when I have the array declared in the structure, but it gives junk output when I declare it as a pointer in the structure and assign a global array to this pointer, as a part of the pointer initialization.

All this code is being run on MS-VC 6.0/Windows setup/Intel-x86.

I tried below things:

  1. Suspected structure padding/alignment but could not get any leads? If at all structure alignment could be a culprit how can i proceed to narrow it down and confirm it?

  2. I have made sure that in both cases the array is initialized to some default values, say 0 before its first use, and its not being used before initialization.

  3. I tried using global array as well as malloc based memory for this newly declared array. Same result, junk output.

How can I zero in on the problem? Any pointers would be helpful.

  • 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-14T02:54:58+00:00Added an answer on May 14, 2026 at 2:54 am

    Is it possible you are using sizeof anywhere on the structure field? sizeof(int[576]) != sizeof(int*).

    This should be the only visible difference between the two.

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

Sidebar

Related Questions

I have some code in VB6 which creates a moderately-large tree structure (a few
I have code which has a drop down list. And when a certain option
I have code which needs to do something like this There is a list
I have code which performs query on Jboss server. It has JNDI based datasource
I have this code which reads all the files from a directory. File textFolder
I have a class structure which is template<int T> class MyClass { public: MyClass(){};
I have code structure in which I have class file, template file and controller
I have some code which connects to a URL to download a file, and
I have some code which utilizes parameterized queries to prevent against injection, but I
I have upgraded some VB6 code, which uses fixed length strings in custom types,

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.