hi:
in c,i use :
int a[5],b[5]={1,2,3,4,5};
struct {
int c[5];
}aaa,bbb;
bbb.c[0]=bbb.c[1]=bbb.c[2]=bbb.c[3]=bbb.c[4]=2;
1) a=b; //compile error;
2) aaa=bbb
1.what's differ between 1),2)?
2.why i can't init bbb by bbb.c[5]={2,2,2,2,2};
thx!! 3 1548 la*********@gmail.com said:
hi:
in c,i use :
int a[5],b[5]={1,2,3,4,5};
struct {
int c[5];
}aaa,bbb;
bbb.c[0]=bbb.c[1]=bbb.c[2]=bbb.c[3]=bbb.c[4]=2;
1) a=b; //compile error;
2) aaa=bbb
1.what's differ between 1),2)?
You can't assign to an array. You /can/ assign to a struct. Why? Well,
because. There doesn't seem to be any better reason than that. It's
just one of them things.
2.why i can't init bbb by bbb.c[5]={2,2,2,2,2};
struct {
int c[5];
} aaa, bbb = { { 2, 2, 2, 2, 2 } };
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at the above domain, - www.
On 3ÔÂ16ÈÕ, ÏÂÎç1ʱ54·Ö, Richard Heathfield <r...@see.sig.invalidwrote:
langog.i...@gmail.com said:
hi:
in c,i use :
int a[5],b[5]={1,2,3,4,5};
struct {
int c[5];
}aaa,bbb;
bbb.c[0]=bbb.c[1]=bbb.c[2]=bbb.c[3]=bbb.c[4]=2;
1) a=b; //compile error;
2) aaa=bbb
1.what's differ between 1),2)?
You can't assign to an array. You /can/ assign to a struct. Why? Well,
because. There doesn't seem to be any better reason than that. It's
just one of them things.
2.why i can't init bbb by bbb.c[5]={2,2,2,2,2};
struct {
int c[5];
} aaa, bbb = { { 2, 2, 2, 2, 2 } };
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999http://www.cpax.org.uk
email: rjh at the above domain, - www.
thx rjh!!
but the answer without reason.
if i want to change the value of bbb ,how to do it simply?
can u figure the c's object modle in memory? la*********@gmail.com wrote:
On 3ÔÂ16ÈÕ, ÏÂÎç1ʱ54·Ö, Richard Heathfield <r...@see.sig.invalidwrote:
langog.i...@gmail.com said:
in c,i use :
Could you not not use abbreviations like "u"? It is clearer if you use
"I"
rather than "i". Things are clearer if you use standard english rather
than
txt-speak.
Also don't post the same thing multiple times.
int a[5],b[5]={1,2,3,4,5};
struct {
int c[5];
}aaa,bbb;
bbb.c[0]=bbb.c[1]=bbb.c[2]=bbb.c[3]=bbb.c[4]=2;
1) a=b; //compile error;
2) aaa=bbb
1.what's differ between 1),2)?
You can't assign to an array. You /can/ assign to a struct. Why? Well,
because. There doesn't seem to be any better reason than that. It's
just one of them things.
2.why i can't init bbb by bbb.c[5]={2,2,2,2,2};
struct {
int c[5];
} aaa, bbb = { { 2, 2, 2, 2, 2 } };
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999http://www.cpax.org.uk
email: rjh at the above domain, - www.
don't quote .sigs (anything after "--<space>") unless you are
commenting
on them
but the answer without reason.
yep. The answer is "because" or "ask Dennis" (the designer of the
language).
if i want to change the value of bbb ,how to do it simply?
I suppose you could set up a default value.
struct
{
int c[5];
} aaa, bbb, def_bbb = { { 2, 2, 2, 2, 2 } };
/* do things to bbb */
/* reset to default */
bbb = def_bbb;
can u figure the c's object modle in memory?
"model"? Why? Why do you need to know this? What are you trying to do?
The ints of C will be in increasing order in memory. Some types may
need padding
between the array elements, but this is unlikely with ints.
--
Nick Keighley This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Sam |
last post by:
Hello all
I have a two dimensional array (the dimensions are not known) that
needs to be passed
to fortran from c++, allocate the dimensions of the array in fortran
code, do some filling up
of...
|
by: Kieran Simkin |
last post by:
Hi,
I wonder if anyone can help me, I've been headscratching for a few hours
over this.
Basically, I've defined a struct called cache_object:
struct cache_object {
char hostname;
char ipaddr;...
|
by: Eric Smith |
last post by:
Is a structure containing an incomplete array as its last element (per
paragraph 2 of section 6.7.2.1 of ISO/IEC 9899:1999 (E)) itself an
incomplete type? That appears to be indicated by paragraph...
|
by: mrhicks |
last post by:
Hello all,
I need some advice/help on a particular problem I am having. I have
a basic struct called "indv_rpt_rply" that holds information for a
particular device in our system which I will...
|
by: Adam Warner |
last post by:
Hi all,
With this structure that records the length of an array of pointers as its
first member:
struct array {
ptrdiff_t length;
void *ptr;
};
|
by: Cybertof |
last post by:
Hello,
Is it possible to convert a VB6 Array of Struct
to
a C# Array Of Struct ?
The test context is a C# application calling a VB6 ActiveX DLL Function
using UDT (User Defined Type) and...
|
by: Sam |
last post by:
Hello I have a structure called Company.
struct Company
{
char *employee;
char *employee_address;
};
I want to build an array of this structure but the number of employees
will change...
|
by: gcary |
last post by:
I am having trouble figuring out how to declare a pointer to an array
of structures and initializing the pointer with a value. I've looked
at older posts in this group, and tried a solution that...
|
by: Cyn |
last post by:
Hi,
I want to create a general array structure which can hold all types.
Something like this:
struct ARRAY
{
void **array;
size_t size;
};
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |