| | |
Trouble with pointers
Thread Solved |
•
•
Join Date: Nov 2008
Posts: 36
Reputation:
Solved Threads: 0
Hi,
In this piece of code in my program I am receiving the following error request for member âyâ in something not a structure or union.
I can't seem use the data in psd. Can someone please help?
Thanks
In this piece of code in my program I am receiving the following error request for member âyâ in something not a structure or union.
c Syntax (Toggle Plain Text)
struct intpair { int x ; int y ; } ; struct intpair makeintpair(int x, int y) { struct intpair temp ; temp.x = x ; temp.y = y ; return temp ; } struct intpair shared_data = makeintpair(5, 0) ; shared_data.y=5; /* Declare and define data to be be */ /* shared by code running on threads. */ struct intpair *psd ; /* Declare & define pointer to shared */ psd = &shared_data ; /* data for threads (see below) to use to */ /* access shared data. */ printf("%d",psd.y);
I can't seem use the data in psd. Can someone please help?
Thanks
In line:20 ie
psd is used to access y by dot(.) operator which is wrong because psd is a pointer and to access y you must use ->(arrow operator) ie
c Syntax (Toggle Plain Text)
printf("%d",psd.y);
psd is used to access y by dot(.) operator which is wrong because psd is a pointer and to access y you must use ->(arrow operator) ie
c Syntax (Toggle Plain Text)
printf("%d",psd->y);
When you think you have done a lot, then be ready for YOUR downfall.
![]() |
Similar Threads
- Hey Just started new topic with arrays, and having some trouble please help (C++)
- Trouble with Pointers (C)
- Trouble with Pointers and Arrays (C)
- Trouble with pointers in card game. (C)
- Mouse cursor trouble on a two-monitor system (USB Devices and other Peripherals)
- Sorting arrays of pointers with function? (C)
Other Threads in the C Forum
- Previous Thread: need urgent responce please!
- Next Thread: Warning: Comparison between pointer and integer (mingw 5.1.4)
| Thread Tools | Search this Thread |
#include * adobe ansi api array asterisks binarysearch centimeter changingto char character cm copyimagefile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax database directory dynamic execv feet fgets file fork frequency function getlasterror getlogicaldrivestrin givemetehcodez global grade graphics gtkgcurlcompiling gtkwinlinux hacking highest histogram include incrementoperators infiniteloop input interest kernel keyboard kilometer linked linkedlist linux linuxsegmentationfault list locate logical_drives looping loopinsideloop. lowest match matrix meter microsoft mqqueue number odf opendocumentformat owf pattern pdf performance pointer posix probleminc process program programming radix recursion recv repetition research reversing scanf segmentationfault sequential shape single socket socketprograming standard string systemcall threads turboc unix user voidmain() wab whythiscodecausesegmentationfault windows.h windowsapi





