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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:28:07+00:00 2026-05-27T16:28:07+00:00

Lets have the files with the following contents: file1.cpp : double array[100]; file2.cpp (client

  • 0

Lets have the files with the following contents:

file1.cpp: double array[100];

file2.cpp (client of file1.cpp):

/// What the difference between this:
extern double* array;

/// and this?
extern double array[];

If I use array declared in the first way I receive segfault. If second, it works ok. It confuses me, since in a regular C++ programm I can easily do the following and these objects would be equal:

double array[100];
double* same_array = array;

/// array[0] is equal to same_array[0] here
/// But why they are not equal in the example with extern?
  • 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-27T16:28:08+00:00Added an answer on May 27, 2026 at 4:28 pm

    The difference is that first is an pointer to the type double
    and second is an array of double.

    Important thing to note here is:

    Arrays are not Pointers!

    An expression with array type (which could be an array name) will convert to a pointer anytime an array type is not legal, but a pointer type is.

    double array[100];
    double* same_array = array;
    

    As per the rule mentioned,In above the array name decays in to a pointer to its first element.

    Why does your program crash?
    An array declaration creates an array which occupies some memory depending on the storage class(where is declared).
    While a pointer just creates an pointer which points to some address. You would explicitly need to made it point to some valid object to be able to use it.

    This should be a good read:
    How do I use arrays in C++?

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

Sidebar

Related Questions

Lets say a directory has two files. Here are the contents File1.txt tagstart random
I have a text file (lets call it file1.txt), it contains the following lines:
I have 2 mxml files, lets say main.mxml and child.mxml. Now lets say I
I have an Air application that lets users import jpg, png and swf files
Let's say you have a text file like this one: http://www.gutenberg.org/files/17921/17921-8.txt Does anyone has
Let's say I have this Hello.scala. object HelloWorld { def main(args: Array[String]) { println(Hello,
Lets say i have a text file with following content: Hello! How are you?
Lets say I have a text file MyFile.txt with following content: hellosam whatsup mynameisjohn
I have found the following asp.net code to be very useful when serving files
I have a simple application with the following code: FileInfo[] files = (new DirectoryInfo(initialDirectory)).GetFiles();

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.