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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:37:48+00:00 2026-06-03T05:37:48+00:00

Yes, I’ve read this question & answers: Passing an array by reference in C?

  • 0

Yes, I’ve read this question & answers: Passing an array by reference in C?. I have a similar problem and implemented the same idea from that question.

However, I still get an error from the following code:

#include <iostream>

void FillArray(int** myArray)
{
   free( *myArray ) ;
   * myArray = (int*) malloc(sizeof(int) * 2);

   *myArray[0] = 1;
   *myArray[1] = 2;
}

int main()
{
   int* myArray = NULL;
   FillArray(& myArray);    
   return 0;
}

I got the following run-time error right after the FillArray function ends:

Unhandled exception at 0x773115de in Program.exe 0xC00000005: Access violation writing location 0xcccccccccc.

I’m using Visual Studio, opened Visual C++ Empty Project. And the file named main.cpp. Does that mean it’s compiled with C++ compiler instead of C compiler? If so, how can I open a file which will be compiled only C compiler? I tried renaming main.cpp with main.c, but still have the same problem. (I’m asking this question, because I read some about “pass by reference” and saw that it’s different in C and C++.)

Sorry for this very fundamental question.

I will be appreciated for any help,

Sait.

  • 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-06-03T05:37:49+00:00Added an answer on June 3, 2026 at 5:37 am

    Precedence is not working as you expect it to be. Try these:

    (*myArray)[0] = 1;
    (*myArray)[1] = 2;
    

    (Note: iostream is not C. It’s C++.)

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

Sidebar

Related Questions

Yes, I have already asked this question, but the problem is much more specific.
Yes, I've read the countless questions regarding the very same problem. My code is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Yes, I have googled this question and even referred to my textbook (PHP by
Yes I have seen This question But it's for php. I'm still new to
Yes, I'm aware that this question has already been post, but ... I'm looking
Yes, this sounds like a simple question, and it probably is. But when i
Yes i have been through the other questions that are related to this, but
YES, I have been looking for answers and couldn't find anything that worked or
Yes, another IE-only problem for your Thursday. :) http://jsfiddle.net/dex3703/nwTUm/ This layout looks fine in

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.