Results 1 to 6 of 6

Thread: C++

  1. #1
    Registered+
    Join Date
    Jul 2003
    Posts
    31
    Thanks
    0
    Thanked
    0 times in 0 posts

    C++

    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

  2. #2
    Commander Keen
    Join Date
    Nov 2003
    Location
    217.27.240.214
    Posts
    624
    Thanks
    0
    Thanked
    0 times in 0 posts
    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 ?

  3. #3
    Registered+
    Join Date
    Jul 2003
    Posts
    31
    Thanks
    0
    Thanked
    0 times in 0 posts
    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

  4. #4
    Commander Keen
    Join Date
    Nov 2003
    Location
    217.27.240.214
    Posts
    624
    Thanks
    0
    Thanked
    0 times in 0 posts
    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.

  5. #5
    Registered+
    Join Date
    Jul 2003
    Posts
    31
    Thanks
    0
    Thanked
    0 times in 0 posts
    Hi, I will have a go at this tomorrow. Thanks for taking the time out to have a go bud, much appreciated.

  6. #6
    Commander Keen
    Join Date
    Nov 2003
    Location
    217.27.240.214
    Posts
    624
    Thanks
    0
    Thanked
    0 times in 0 posts
    Did This Work... Don't leave me hanging here !

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •