I understand *why* this produces an error and how to correct it, (add
parentheses) but the error itself is a bit eclectic? As I am sure this
will arise again, could anyone throw some logic at it.
int main (int argc, const char * argv[]) {
struct point {
int x;
int y;
};
struct point *pp;
struct point origin;
pp= &origin;
origin = makepoint(23, 67);
printf("%d, %d\n", (*pp).x, *pp.y); /*error: request for member 'y'
in something not a structure or union*/
}
Thanks in advance 6 2243
On Aug 23, 6:41 pm, mdh <m...@comcast.netwrote:
I understand *why* this produces an error and how to correct it, (add
parentheses) but the error itself is a bit eclectic? As I am sure this
will arise again, could anyone throw some logic at it.
int main (int argc, const char * argv[]) {
struct point {
int x;
int y;
};
struct point *pp;
struct point origin;
pp= &origin;
origin = makepoint(23, 67);
printf("%d, %d\n", (*pp).x, *pp.y); /*error: request for member 'y'
in something not a structure or union*/
}
See operator precedence.
.. bounds tigher than *
*pp.y means *(pp.y)
pp is a pointer, . requires structure or union
mdh wrote:
I understand *why* this produces an error and how to correct it, (add
parentheses) but the error itself is a bit eclectic? As I am sure this
will arise again, could anyone throw some logic at it.
int main (int argc, const char * argv[]) {
struct point {
int x;
int y;
};
struct point *pp;
struct point origin;
pp= &origin;
origin = makepoint(23, 67);
printf("%d, %d\n", (*pp).x, *pp.y); /*error: request for member 'y'
in something not a structure or union*/
}
Thanks in advance
It's a snytax error. As written *pp.y assumes pp a structure and y a
pointer to int. None of that is true.
--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
On Aug 23, 8:57*am, Joe Wright <joewwri...@comcast.netwrote:
mdh wrote:
I understand *why* this produces an error and how to correct it,
snip
int main (int argc, const char * argv[]) {
struct point {
* *int x;
* *int y;
};
* *struct point *pp;
* *struct point origin;
* *pp= &origin;
>
* *printf("%d, %d\n", (*pp).x, *pp.y); */*error: request for member 'y'
in something not a structure or union*/
>
It's a snytax error. As written *pp.y assumes pp a structure and y a
pointer to int. None of that is true.
Thanks Joe...yes that makes sense. One more eclectism falls :-)
On Aug 23, 8:57*am, vipps...@gmail.com wrote:
>
pp is a pointer, . requires structure or union
thanks
On Sat, 23 Aug 2008 11:57:15 -0400, Joe Wright wrote:
mdh wrote:
> struct point *pp; [...] printf("%d, %d\n", (*pp).x, *pp.y); /*error: request for member
'y'
>in something not a structure or union*/
It's a snytax error.
No, it's not, unless snytax is an intentional misspelling that I am not
familiar with. *pp.y is syntactically valid, but semantically invalid.
On 23 Aug, 16:41, mdh <m...@comcast.netwrote:
I understand *why* this produces an error and how to correct it, (add
parentheses) but the error itself is a bit eclectic? As I am sure this
will arise again, could anyone throw some logic at it.
int main (int argc, const char * argv[]) {
struct point {
* * * * int x;
* * * * int y;
};
* * * * struct point *pp;
* * * * struct point origin;
* * * * pp= &origin;
* * * * origin = makepoint(23, 67);
* * * * printf("%d, %d\n", (*pp).x, *pp.y); */*error: request for member 'y'
in something not a structure or union*/
}
Thanks in advance
Erm, it seems to make perfect sense to me. The '.' means you are
accessing a member of a struct or union, so pp.y means "access the
member called 'y' of the struct or union pp". Which is wrong, beacause
pp is not a struct or union - it is a pointer to a struct. So pp isn't
a struct or a union, and it doesn't have members. So it's an error to
access member 'y' of it. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: kosuke |
last post by:
I keep getting the following error/warning message when using the
python based program getmail4:
/usr/lib/python2.3/optparse.py:668: FutureWarning: %u/%o/%x/%X of
negative int will return a...
|
by: Bill |
last post by:
I have perhaps not explained myself clearly, so I'll try it this way.
In the code below, where it says "I'd like to include my navigation
bar here" is the place I'd like to insert a navigation bar...
|
by: Steve Bywaters |
last post by:
There are several hundred of my client's franchisees happily accessing my
ASP/VBscript web site... but one - just one - has reported the following:
"I have been trying to log onto the LSM since...
|
by: dmiller23462 |
last post by:
Hey guys, I'm back again....I've got the results displaying that I
wanted but instead of having a "next" or "previous" link displayed I
am getting the error msg below (I actually get the data that...
|
by: Bob |
last post by:
Hi Everybody
I hope you can help.
2 related questions.
1. I am looking for a way to replace the confusing message box that comes up when a user trys to
open a form without putting data in...
| |
by: Thelma Lubkin |
last post by:
I use code extensively; I probably overuse it. But I've been using
error trapping very sparingly, and now I've been trapped by that.
A form that works for me on the system I'm using, apparently...
|
by: Blah |
last post by:
In MSDN documentation it states..
Remarks
The constant declaration can declare multiple constants,
for example:
public const double x = 1.0, y = 2.0, z = 3.0;
The static modifier is not...
|
by: Anthony England |
last post by:
(sorry for the likely repost, but it is still not showing on my news server
and after that much typing, I don't want to lose it)
I am considering general error handling routines and have...
|
by: Tony Girgenti |
last post by:
Hello.
I'm developing and testing a web application using VS.NET 2003, VB, .NET
Framework 1.1.4322, ASP.NET 1.1.4322 and IIS5.1 on a WIN XP Pro, SP2
computer. I'm using a web form.
I'm...
|
by: i |
last post by:
#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<string.h>
char ch;
int n,m;
void main();
char check(int,int,char);
void cash(int,int,char);
void debit_card(int,int,char);
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |