| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | My last post about the violation ac |
Hallo, Daniel! *** Am Donnerstag 25. Juli 1996 um 02:01 schrieb Daniel Lynes an Thomas Seeling: TS>> *x++; This is evaluated as x++, plus its side-effect is the value of *x. DL> test.c(5): Warning! W302: Expression is only useful for its side effects The compiler tells you this. TS>> /* this is illegal, since x does not contain a "legal" pointer */ TS>> z=*x; It is illegal, *if* "int *x" is only a pointer to _one_ int, not to an array of (at least 2) ints. The pointer is incremented, but it does contain any legal pointer value. So, consequently, accessing the value "behind" that pointer is illegal as well. DL> However, the compiler does not spit out an error for this; nor, do I The compiler cannot know that you just send one integer to the function. "int *x" is either used to change the value of x, or to access a whole array of ints. DL> pointer x, to the variable, z. Why is this illegal? Did you try DL> compiling it? I am used to C for quite some years now. This is a typical beginner's mistake, and I don't need to start the compiler to know where the fault is. DL> number, lending to the fact that *x++; is only useful for its side DL> effects. i.e. its behaviour is unpredictable. It is not wrong to use a statement "*x++", but it's useless. You want to write (*x)++. Have a look at the operator precedences in a C learning or reference book. You could either write "++*x". This is not specific to OS/2, so you should continue discussing this in C_ECHO, comp.lang.c or a similar local newsgroup. Tschau...Thomas --- E3-32/1.11-32/2.50+* Origin: Die TeX-Box +49-6034-930021 V.34 -930022 ISDN 24h (2:244/1130.42) SEEN-BY: 50/99 270/101 620/243 625/100 711/401 409 410 413 430 808 809 934 SEEN-BY: 711/955 712/407 515 624 628 713/888 800/1 @PATH: 244/1130 24/999 888 396/1 270/101 712/515 711/808 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.