Say I have:
char foo[][];
char** bar;
In my understanding, these two have the same meaning in memory.
Could someone elucidate upon these two types and their meanings?
Thanks,
Paul 7 1605
Paul wrote: Say I have: char foo[][]; char** bar;
In my understanding, these two have the same meaning in memory.
What is "meaning in memory"?
Could someone elucidate upon these two types and their meanings?
The former, IIUIC, is an error, since to declare a multidimensiona l array
you have to specify all sizes but the inner-most one.
V
char foo[][]; is an invalid declaration. Only the first dimension size
can be omitted, and even then you're expected either to be using a
declaration without the definition, or initializing the array such that
the size can be calculated from the initializer. these two have the same meaning in memory.
Not necessarily. Perhaps if you post some more code, and mention what
system and implementation you're using, a more thorough answer can be
given.
-Ren
char foo[][]; is an invalid declaration. Only the first dimension size
can be omitted, and even then you're expected either to be using a
declaration without the definition, or initializing the array such that
the size can be calculated from the initializer. these two have the same meaning in memory.
Not necessarily. Perhaps if you post some more code, and mention what
system and implementation you're using, a more thorough answer can be
given.
-Ren
Victor Bazarov wrote: Paul wrote: Say I have: char foo[][]; char** bar;
In my understanding, these two have the same meaning in memory.
What is "meaning in memory"?
Could someone elucidate upon these two types and their meanings?
The former, IIUIC, is an error, since to declare a multidimensiona l array you have to specify all sizes but the inner-most one.
They way they are written, those are variable declarations, not
function parameters, so the first case would have to be initialized as
well.
char foo[][6] = {"one", "two", "three"};
Then the compiler can count the initializers and compute the missing
dimension.
Now, if used in a function declaration, then you can have:
void bar (char foo[][6]);
It's definitely not equivalent to:
void bar (char **foo);
Brian ma*********@acm .org wrote: char foo[][]; is an invalid declaration. Only the first dimension size can be omitted, and even then you're expected either to be using a declaration without the definition, or initializing the array such that the size can be calculated from the initializer.
these two have the same meaning in memory.
Not necessarily. Perhaps if you post some more code, and mention what system and implementation you're using, a more thorough answer can be given.
-Ren
Let's say:
char foo[16][16];
char **bar;
bar = new char*[16];
for(int i = 0; i < 16; i++)
{
bar[i] = new char[16];
}
It is my understanding that foo and bar can be accessed and passed
around in similiar manner and maintain the same meaning.
I also think they can be cast from one to the next without error.
I have a suspicion I'm wrong, however. :-)
-Paul
Paul wrote: ma*********@acm .org wrote:
char foo[][]; is an invalid declaration. Only the first dimension size can be omitted, and even then you're expected either to be using a declaration without the definition, or initializing the array such that the size can be calculated from the initializer.
these two have the same meaning in memory.
Not necessarily. Perhaps if you post some more code, and mention what system and implementation you're using, a more thorough answer can be given.
-Ren
Let's say:
char foo[16][16]; char **bar;
bar = new char*[16]; for(int i = 0; i < 16; i++) { bar[i] = new char[16]; }
It is my understanding that foo and bar can be accessed and passed around in similiar manner and maintain the same meaning.
Similar, maybe. Same meaning, no. Same purpose, perhaps.
I also think they can be cast from one to the next without error.
That's incorrect.
I have a suspicion I'm wrong, however. :-)
Yes, unfortunately, you are. 'foo' is an array of arrays, while 'bar'
is [a pointer to] an array of pointers. They have different types and
therefore behave differently in certain situations. Also, the derived
objects, *bar and *foo have different types, although now they are more
compatible than before, you may convert decltype(*foo) to decltype(*bar).
[Note: I use 'decltype' to convey the meaning, there is no such construct
in C++ yet].
The important difference (and that's where casting comes into play) is
that the memory layouts of what is designated by 'foo' and by 'bar' are
vastly different.
V
Paul wrote: ma*********@acm .org wrote: char foo[][]; is an invalid declaration. Only the first dimension size can be omitted, and even then you're expected either to be using a declaration without the definition, or initializing the array such that the size can be calculated from the initializer.
these two have the same meaning in memory. Not necessarily. Perhaps if you post some more code, and mention what system and implementation you're using, a more thorough answer can be given.
-Ren
Let's say:
char foo[16][16]; char **bar;
bar = new char*[16]; for(int i = 0; i < 16; i++) { bar[i] = new char[16]; }
It is my understanding that foo and bar can be accessed and passed around in similiar manner and maintain the same meaning.
Accessed, pretty much yes. Passed? Absolutely not. http://www.eskimo.com/~scs/C-faq/q6.18.html
I also think they can be cast from one to the next without error.
You can cast the array to the pointer and it won't cause an error
(because you did a cast). Doesn't mean it will work. The two constructs
will have different layouts in memory, and the pointer strides are
different. The name of array is converted to type pointer to array 16
of char.
Just disabuse yourself of this notion. Read ALL the FAQs on arrays and
pointers in the C FAQ (it's more useful for these questions).
Brian This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Darren Dale |
last post by:
I love the language. I love the community. My only complaint is that
Python for Windows is built with Visual Studio.
It is too difficult to build python, or a module, from source. This is
what open source is all about, isnt it? I even have a copy of visual
studio, and I still cant build modules from source, because my academic
copy is version 7. As a scientist funded by the NSF, I feel compelled to
do all my work using free software (I...
|
by: Richard Cornford |
last post by:
I am interested in hearing opinions on the semantic meaning of FORM
(elements) in HTML.
I have to start of apologising because this question arose in a context
that is not applicable to the Internet. Specifically, marking up a
document that will contain multiple related form controls (intended
exclusively for client-side scripting) that would never be intended to
be submitted. I realise that that concept is a non-starter in an
Internet...
|
by: pr10n |
last post by:
Hello, all! I'm working on a personal blog and I'm trying to make it's
markup more semantic, using the right elements, removing needless div's
and so on.
I was wondering if someone would be kind enough to peek at the code and
see if they have any suggestions. I realize I am over using the list and
header elements. I am also in the process of shifting the content blocks
around in the code to get the meat of the site displayed first.
...
|
by: dayzman |
last post by:
Hi,
I'm in need of a program that extracts the semantic structure of HTML
pages -- a program that groups paragraphs with the corresponding
headings etc. I know it's not too difficult to extract well structured
documents, e.g. formal essays. However, with complicated sites like CNN
and CNet, where many tables are used to align text, to me it'd become
extremely difficult. Does anyone know of any existing applications? If
not, should it be...
|
by: dayzman |
last post by:
Hi,
I'm interested in projects evolve about extracing semantic structure of
HTML documents. What I mean by extracting semantic structure is to
analyse HTML doc and outputs a model (perhaps a tree structure) that
relates paragraphs to headings/sub headings. It should be a difficult
problem, since HTML is a structure language. Does anyone know of any
existing research?
Cheers,
| |
by: dayzman |
last post by:
Hi,
I've read somewhere that feature-based analysis can be used to extract
the semantic structure of HTML documents. By semantic structure, they
mean the model of the rendered view a reader sees. Now, my question is,
what should such feature-based analysis involve? What exactly is a
feature-based analysis?
Please help.
|
by: Xah Lee |
last post by:
Tabs versus Spaces in Source Code
Xah Lee, 2006-05-13
In coding a computer program, there's often the choices of tabs or
spaces for code indentation. There is a large amount of confusion about
which is better. It has become what's known as “religious war” —
a heated fight over trivia. In this essay, i like to explain what is
the situation behind it, and which is proper.
|
by: Scott Abel |
last post by:
Tony Self of HyperWrite presents an interesting and informative article
entitled "Semantic, Structured Authoring: The Challenge for Technical
Writers" that is sure to be of use to many technical writers struggling
to find themselves in the changing world of structured XML authoring
and content management. Check it out and leave a comment to let us know
what you think.
http://www.thecontentwrangler.com
The Content Wrangler, Inc.
|
by: rshepard |
last post by:
I'm a bit embarrassed to have to ask for help on this, but I'm not finding
the solution in the docs I have here.
Data are assembled for writing to a database table. A representative tuple
looks like this:
('eco', "(u'Roads',)", 0.073969887301348305)
Pysqlite doesn't like the format of the middle term:
pysqlite2.dbapi2.InterfaceError: Error binding parameter 1 - probably
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |