Hi all,
I have got a simple question about the
#define command: Can I use it for array
initialisation?
E.g.
#define ARRAYINIT { {0, 1}, {2,3} }
....
int main ( void )
{
int somestuff[][] = ARRAYINIT;
...
}
Thanks,
Michael 7 38527
"Michael" <mi****@gmx.net> wrote in message
news:cc**********@rzcomm2.rz.tu-bs.de... I have got a simple question about the #define command: Can I use it for array initialisation?
E.g.
#define ARRAYINIT { {0, 1}, {2,3} }
... int main ( void ) { int somestuff[][] = ARRAYINIT; ... }
Yep. After the preprocessing phase the source will read:
....
int main ( void )
{
int somestuff[][] = { {0, 1}, {2,3} };
...
}
Alex
Alex Fraser wrote: Yep. After the preprocessing phase the source will read:
... int main ( void ) { int somestuff[][] = { {0, 1}, {2,3} }; ... }
Alex
Hi Alex,
thanks for the quick response.
Regards
Michael
> Yes, but the dimensions of the array should be added int somestuff[2][2] = ARRAYINIT;
only the lefmost dimension can be ommited :
int somestuff[][2] = ARRAYINIT;
Hi,
yeah, my compiler already complaint about that. But I got
an other question. My compiler complains about an Yx1 array
like:
int somestuff[6][1] = { {1}, {1}, {1}, {1}, {1}, {1} };
I know, I can do it with one dimension, but due the programm
structure I would prefer to realize the above array.
Is the a chance?
Thanks,
Michael
In 'comp.lang.c', Michael <mi****@gmx.net> wrote: My compiler complains about an Yx1 array like:
int somestuff[6][1] = { {1}, {1}, {1}, {1}, {1}, {1} };
I know, I can do it with one dimension, but due the programm structure I would prefer to realize the above array.
or
int somestuff[][1] = { {1}, {1}, {1}, {1}, {1}, {1} };
Well, I don't see what does your compiler complain about. Sounds good to me.
Must be something else.
--
-ed- get my email here: http://marreduspam.com/ad672570
The C-language FAQ: http://www.eskimo.com/~scs/C-faq/top.html
C-reference: http://www.dinkumware.com/manuals/reader.aspx?lib=c99
FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/
Emmanuel Delahaye wrote:
[...] Well, I don't see what does your compiler complain about. Sounds good to me. Must be something else.
Exactly. You are right it was something else.
Thanks again ....
Michael This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Christopher Jeris |
last post by:
I am relatively new to JavaScript, though not to programming, and
I'm having trouble finding the idiomatic JS solution to the following
problem.
I have a table with (say) fields f1, f2, f3. I...
|
by: Remi Bastide |
last post by:
Is is possible to initialize a javascript associative array inline, as
you would do in PHP, e.g. :
<?php
$a = array("abc" => "def", "ghi" => "jkl");
?>
|
by: Frank M. |
last post by:
I'm trying to declare an array of pointers to structures so that I can make
the last element a NULL pointer. I figure that it would more easily allow
my library routines to know when to stop...
|
by: Vasileios Zografos |
last post by:
Hello,
can anyone please tell me if there is any difference between the two:
double Array1;
and
|
by: Louis Caron |
last post by:
I am facing the following problem:
- I have to build a const array containing functions pointers
- the indexes for this array are generated automatically by a tool (not my property)
How do I...
|
by: mark.bergman |
last post by:
Running lint on code initialising a local 2-D array gives a warning.
void f(void)
{
int a = { 0 };
...
lint gives "warning: Partially elided initialisation..."
Should this be happening,...
|
by: jamx |
last post by:
How can you initialize an array, in the initialization list of a
constructor ??
SomeClass
{
public:
SomeClass() : *init here* { }
private:
int some_array;
};
|
by: dan |
last post by:
I would like to have the preprocessor automatically generate the
number of array elements requested. Each element is zero. The elements
get pasted into a larger array. The other elements may be...
|
by: mdh |
last post by:
I am still having a problem understanding K&RII on p 112. I have
looked at the FAQs --which I am sure answer it in a way that I have
missed, so here goes.
A 2-dim array, (per K&R) is really a...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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,...
|
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...
|
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...
| |