By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
 448,793 Members | 1,149 Online
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,793 IT Pros & Developers. It's quick & easy.

# Syntax issue

 P: n/a Hey I have a CODE that some 1 wrote however he use this line x= (y=4,z=6); ( by the way the output of this line is x=6 , y=4 , z=6 ) i was wondring in what situation i will have to use it? and does it good for? Second thing Can some 1 explain me the way to use the MAX_RAND while using rand() I dont understand what does the MAX_RAND do 10x in advance Aug 24 '06 #1
Share this Question
12 Replies

 P: n/a Chief wrote: Hey I have a CODE that some 1 wrote however he use this line x= (y=4,z=6); ( by the way the output of this line is x=6 , y=4 , z=6 ) i was wondring in what situation i will have to use it? and does it good for? Second thing Can some 1 explain me the way to use the MAX_RAND while using rand() I dont understand what does the MAX_RAND do 10x in advance dude 4 yr 1st ques its the comma ope8r dont have 2 use it if u dont want 2 handy some timz anyway c book has all u need 2 no 4 sure 2nd ques no such animal hope this helps ciao babe -- Eric Sosman es*****@acm-dot-org.invalid Aug 25 '06 #2

 P: n/a Eric Sosman wrote: Chief wrote: Hey I have a CODE that some 1 wrote however he use this line x= (y=4,z=6); ( by the way the output of this line is x=6 , y=4 , z=6 ) i was wondring in what situation i will have to use it? and does it good for? Second thing Can some 1 explain me the way to use the MAX_RAND while using rand() I dont understand what does the MAX_RAND do 10x in advance dude 4 yr 1st ques its the comma ope8r dont have 2 use it if u dont want 2 handy some timz anyway c book has all u need 2 no 4 sure 2nd ques no such animal hope this helps ciao babe Medic! MEDIC! Even Eric's caught it now. Nobody's safe. Condoms on fingers everyone. Aug 25 '06 #3

 P: n/a Chief posted: Hey I have a CODE Culminary Orthogonal Device Ensembles are off-topic here. x= (y=4,z=6); ( by the way the output of this line is x=6 , y=4 , z=6 ) In C++, maybe. In C, assignment to a variable cannot result in output. i was wondring in what situation i will have to use it? When CODE's enter Relax Mode, they tend to over-iterate through arrays -- the only way to normalise the indexing is by using the comma operator in conjuction with multiple assignments. and does it good for? It works quite well (on modern CPU's). Don't try it on a 486. Second thing Can some 1 explain me the way to use the MAX_RAND while using rand() I dont understand what does the MAX_RAND do Yes, indeed: int max = (MAX_RAND, rand()); (See how I have normalised the over-iteration by using the comma operator in conjunction with mutiple assignments?) 10x in advance Whoa whoa whoa, don't get ahead of yourself! If the algorithm which initialises the CODE is run ten times in advance, the over-iteration will be far too erratic to correct. Any attempt to normalise the indexing at that point will result in hard-disk over-burn -- so let's hope you keep everything backed up. -- Frederick Gotham Aug 25 '06 #4

 P: n/a On Fri, 25 Aug 2006 01:41:15 GMT, Frederick Gotham Chief posted: >Hey I have a CODE Culminary Orthogonal Device Ensembles are off-topic here. >x= (y=4,z=6);( by the way the output of this line is x=6 , y=4 , z=6 ) In C++, maybe. In C, assignment to a variable cannot result in output. If that were true, then code of the form if ((ptr = malloc(10)) == NULL) could never work. The result of evaluating the assignment operator is the value that is assigned to the left operand. The statement evaluates as assign 4 to y discard result assign 6 to z assign result (in this case 6) to x Remove del for email Aug 25 '06 #5

 P: n/a Eric Sosman wrote: Chief wrote: Hey I have a CODE that some 1 wrote however he use this line x= (y=4,z=6); ( by the way the output of this line is x=6 , y=4 , z=6 ) i was wondring in what situation i will have to use it? and does it good for? Second thing Can some 1 explain me the way to use the MAX_RAND while using rand() I dont understand what does the MAX_RAND do 10x in advance dude 4 yr 1st ques its the comma ope8r dont have 2 use it if u dont want 2 handy some timz anyway c book has all u need 2 no 4 sure 2nd ques no such animal hope this helps ciao babe This gets bookmarked ;-) Aug 25 '06 #6

 P: n/a Barry Schwarz wrote: On Fri, 25 Aug 2006 01:41:15 GMT, Frederick Gotham

 P: n/a Barry Schwarz posted: >>In C++, maybe. In C, assignment to a variable cannot result in output. If that were true, then code of the form if ((ptr = malloc(10)) == NULL) could never work. You're correct. I meant to say I was referring to assignments involving simple object names: a = b; In C++, this could result in output (depending on whether there's a user- defined assignment operator for the type "a" is). In C, it can't do anything more than change the value of "a". -- Frederick Gotham Aug 25 '06 #8

 P: n/a Frederick Gotham wrote: Barry Schwarz posted: >In C++, maybe. In C, assignment to a variable cannot result in output. If that were true, then code of the form if ((ptr = malloc(10)) == NULL) could never work. You're correct. I meant to say I was referring to assignments involving simple object names: a = b; In C++, this could result in output (depending on whether there's a user- defined assignment operator for the type "a" is). In C, it can't do anything more than change the value of "a". No legal assignment can result in the printing of output, not just those involving simple object names. Robert Gamble Aug 25 '06 #9

 P: n/a Robert Gamble posted: No legal assignment can result in the printing of output, not just those involving simple object names. #include int main(void) { int a,b,c,d,e,f,g; a = puts("Hello!"); b = puts("Hello!"); c = puts("Hello!"); d = puts("Hello!"); e = puts("Hello!"); f = puts("Hello!"); g = puts("Hello!"); return 0; } -- Frederick Gotham Aug 25 '06 #10

 P: n/a Frederick Gotham wrote: Robert Gamble posted: No legal assignment can result in the printing of output, not just those involving simple object names. #include int main(void) { int a,b,c,d,e,f,g; a = puts("Hello!"); b = puts("Hello!"); c = puts("Hello!"); d = puts("Hello!"); e = puts("Hello!"); f = puts("Hello!"); g = puts("Hello!"); return 0; } Perhaps you don't realize this, but it is the call to the puts function that results in the output, not the assignment of its return value. Robert Gamble Aug 25 '06 #11

 P: n/a In article <11**********************@p79g2000cwp.googlegroups .com>, Robert Gamble No legal assignment can result in the printing of output, not justthose involving simple object names. char *IOP = (char *) 0xffff01e4UL; *IOP = 'h'; *IOP = 'i'; *IOP = '\n'; If address 0xffff01e4 happens to be an IO port, then you could get the printing of output. These assignments *are* legal, and converting an integral type into a pointer is explicitly allowed in the C standard. The result of all of this is implementation defined, sure, but violates no constraints. -- Prototypes are supertypes of their clones. -- maplesoft Aug 25 '06 #12

 P: n/a On 24 Aug 2006 15:38:51 -0700, "Chief" Hey I have a CODE that some 1 wrote however he use this linex= (y=4,z=6);( by the way the output of this line is x=6 , y=4 , z=6 )i was wondring in what situation i will have to use it?and does it good for? I can't think of any good situation in which you will have to use it. It's not good for anything that I can think of. If you worked for me and I came across code like this of yours in a review, I'd tell you that you have two options: Either change the code to something like this: int x = 6; int y = 4; int z = 6; or get up out of your chair and walk down the hall to the HR's office, where you'll be picking up your termination papers. Your (his) code is indeed Standard C code, but it's not appropriate Standard C code, at least for the real world. >Second thing Can some 1 explain me the way to use the MAX_RAND whileusing rand() I dont understand what does the MAX_RAND do It's RAND_MAX, not MAX_RAND. There are some C FAQs that deal with this (search for RAND_MAX at this URL). http://www.faqs.org/faqs/C-faq/faq/ >10x in advance When I see something like "10x", I think of flyfishing tippet. And "10x" is very, very fine--and possibly non-existant--flyfishing tippet. I've never heard of "10x" flyfishing tippet. But that doesn't mean that you don't fish with "10x" flyfishing tippet--perhaps you do. -- jay Aug 31 '06 #13

### This discussion thread is closed

Replies have been disabled for this discussion.