Thread: I can't believe it......I found a way to multiply 2 pointers!!!!!!

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    156

    I can't believe it......I found a way to multiply 2 pointers!!!!!!

    Code:
    /* Demonstrates inline and multiplying pointers */
    #include <iostream>
    #include <windows.h>
    
    inline int ptrmult(int x, int y)
    {
     int *ptr, *scd;
     ptr= &x;
     scd= &y;
     return (*ptr)*(*scd);
    }
    
    int main(int argc, char *argv[])
    {
     int a, b, c;
     cout << "Input a number: ";
      cin >> a;
     cout << "Input a number: ";
      cin >> b;
    
     c= ptrmult(a, b);
     cout << a << " + " << b << "= " << c;
     Sleep(c*a*b+100);
    
     cin.get();
     return 0;
    }
    
    
    
    /*
    multiplying pointers with just one function
    
    int main(int argc, char *argv[])
    {
     int x, y;
     cin >> x >> y;
     int *pointer, *second;
     pointer=&x;
     second= &y;
     cout << (*pointer)*(*second);
    
    
     cin.get();
     return 0;
    }
    
    amazing huh?
    */
    To make this topic have a point, rate my coding. Tell me if I could use a better method of performing such an amazing task.
    Compiler: MingW(IDE: Bloodshed Dev-C++ 4.01)
    Web Site: Zoo Crew
    Forums: Zoo Boards
    E-mail: [email protected]

    "Do you wanna go to jail or do you wanna go home?!?!" - Alonzo(Training Day)

  2. #2
    looking for the truth moemen ahmed's Avatar
    Join Date
    Feb 2002
    Location
    Egypt
    Posts
    161
    execuse me....but i cant c here any amzing thing.all u ve done is just derefrenced the values in the int (which is totally normal thing) and mutliplying it............u didnt multiply the pointers .
    or may be just i cant understand it right !!!!
    Programming is a high logical enjoyable art for both programer and user !!

  3. #3
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    I agree that there's nothing special 'bout it. What you actually doing is multiplying to integers and as far as i know, doing that is not one of the hardest tasks. (actually not even a task at all !)

  4. #4
    Registered User bljonk's Avatar
    Join Date
    Oct 2001
    Posts
    70
    hey!!! chillin man the guy just discovered that's also possible to multiply to numbers using pointers(hahaha).
    Ünicode¬>world = 10.0£

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using pointers to pointers
    By steve1_rm in forum C Programming
    Replies: 18
    Last Post: 05-29-2008, 05:59 AM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. Line Counting
    By 00Sven in forum C Programming
    Replies: 26
    Last Post: 04-02-2006, 08:59 PM
  4. Going out of scope
    By nickname_changed in forum C++ Programming
    Replies: 9
    Last Post: 10-12-2003, 06:27 PM
  5. Pointers on pointers to pointers please...
    By Morgan in forum C Programming
    Replies: 2
    Last Post: 05-16-2003, 11:24 AM