473,326 Members | 2,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

what's diffs in the prog?

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!!
Mar 16 '07 #1
2 1454
In article <et**********@news.yaako.com>,
guoliang <po********@gmail.comwrote:
>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)?
One involves arrays, the other involves structs. Assigning structs is legal,
assigning arrays isn't.
>2.why i can't init bbb by bbb.c[5]={2,2,2,2,2};
Pick one of these:

struct { int c[5]; } aaa, bbb={.c={2,2,2,2,2}};

struct { int c[5]; } aaa, bbb={{2,2,2,2,2}};

struct { int c[5]; } aaa, bbb={2,2,2,2,2};

struct { int c[5]; } aaa, bbb;
memcpy(&bbb.c, (int[5]){2,2,2,2,2});

struct foo { int c[5]; } aaa, bbb;
bbb=(struct foo){.c={2,2,2,2,2}};

struct foo { int c[5]; } aaa, bbb;
bbb=(struct foo){{2,2,2,2,2}};

--
Alan Curry
pa****@world.std.com
Mar 16 '07 #2
guoliang wrote:
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};
because this is assignment not initialisation, although the syntax
looks superficially similar they are not the same thing.
--
Nick Keighley

Mar 16 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ben Eisenberg | last post by:
I'm trying to run a php script setuid. I've tried POSIX_setuid but you have to be root to run this. The files are located on a public access unix system and have me as the owner and nobody as the...
11
by: becte | last post by:
What does the standard say about f(x++) ? 1. x is incremented and then the that value is used in function f, i.e. x++; f(x); 2. the value of x (before ++) is send to f and after returning. x is...
2
by: facicad | last post by:
I would like to set topmost another prog. from my program. Ex: I use AutoCAD, run my prog. from autocad. My prog. is topmost but went I would like to pick some object in autocad, I set TopMost to...
2
smartway
by: smartway | last post by:
Can we use c++ code in c prog or can we include .cpp in c prog. ? If yes ........ How can we do this?
4
by: Signeg | last post by:
Hey guys, I have some work for university and i never used C++ in my life so i'm kinda lost.. But i've still managed to write something woth it. But too bad for me the prog does compile and lunch...
1
by: =?Utf-8?B?YXp6YQ==?= | last post by:
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record. /PROJECT/edit.asp, line 39 <%@ LANGUAGE="JAVASCRIPT" %> <% var refer =...
1
by: laptop | last post by:
hello frnds im new to this forum, please help me . i have a question paper webpage from where i will be taking answers in form of prog in different languages(perl,php,java,c,c++,python).now since im...
37
by: tvnaidu | last post by:
Need to write small prog to measure RMS Current, RMS Voltage and power factor for 50HZ 8 plug power strip, any sample prog?.
8
by: tvnaidu | last post by:
I am running prog with GDB - throws SIG32, why? @localhost config]# gdb prog GNU gdb Red Hat Linux (5.3.90-0.20030710.40rh) Copyright 2003 Free Software Foundation, Inc. GDB is free software,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.