| | |
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 |
* adobe ansi api array asterisks binarysearch calculate centimeter char character cm convert copyanyfile copyimagefile copypdffile cprogramme createcopyoffile createprocess() csyntax directory feet fflush fgets file floatingpointvalidation fork frequency function getlasterror getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling gtkwinlinux hacking highest homework i/o inches infiniteloop interest intmain() kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives match meter microsoft mqqueue mysql number oddnumber odf open opendocumentformat openwebfoundation owf pattern pdf performance posix power probleminc program programming pyramidusingturboccodes read recv recvblocked repetition scanf scheduling segmentationfault send single socketprograming socketprogramming stack standard strchr string suggestions systemcall unix urboc user variable voidmain() wab whythiscodecausesegmentationfault win32api windows.h





