473,320 Members | 1,902 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,320 software developers and data experts.

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 2230
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
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
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
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
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
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
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
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
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
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
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
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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.