Hi guys , I have to try and make a simple program so that two numbers are asked to be entered and then you enter the 2 numbers and using pointers they are output in reverse . Any ideas
Hi guys , I have to try and make a simple program so that two numbers are asked to be entered and then you enter the 2 numbers and using pointers they are output in reverse . Any ideas
my c++ sux... I do java like a daemon however !
If you have never used c before. Then this will be of some help. If you do know a bit of c.... then this pretty much sux as advice !
look for scanf, and printf function explanations.
As for the numbers... What do you mean in reverse ? i.e. user types 1. User types 2. Output -> 2 then 1 ?
Yep user types 1 then2 and output is 2-1 . I know how to use the scanf to get numbers and printf to output but I have to use pointers to reference the numbers ie using a * but dont know . Thanks, mark
int *outFirst ; /* two pointers */
int *outSecond ;
int firstIn, secondIn ; /*Normal ints*/
scanf("%d%d", &firstIn, &secondIn) ;
outFirst = &firstIn ;
outSecond = &secondIn ;
printf("%d%d, outFirst, outSecond) ;
MY C sucks, and I have not tested this at all. But I am pretty sure this does what you want.
outFirst = &firstIn ; This means that outFirst is being assigned the value of the firstIn address in memory. both the out variables are pointers.
Hope this helps.
Hi, I will have a go at this tomorrow. Thanks for taking the time out to have a go bud, much appreciated.
Did This Work... Don't leave me hanging here !
There are currently 1 users browsing this thread. (0 members and 1 guests)