473,508 Members | 2,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error message explained

mdh
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

Aug 23 '08 #1
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
Aug 23 '08 #2
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 ---
Aug 23 '08 #3
mdh
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 :-)
Aug 23 '08 #4
mdh
On Aug 23, 8:57*am, vipps...@gmail.com wrote:
>
pp is a pointer, . requires structure or union

thanks
Aug 23 '08 #5
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.
Aug 23 '08 #6
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.
Aug 23 '08 #7

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

Similar topics

14
1913
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...
5
1845
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...
28
2323
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...
2
6279
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...
5
744
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...
13
4433
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...
20
3532
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...
10
2268
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...
7
11454
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...
9
2932
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);
0
7118
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...
0
7323
Oralloy
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,...
0
7379
jinu1996
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...
1
7038
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...
0
7493
tracyyun
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...
0
5625
agi2029
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,...
0
3192
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...
0
1550
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 ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.