c++ pointer


SUBMITTED BY: Guest

DATE: Oct. 13, 2013, 3:28 a.m.

FORMAT: C++

SIZE: 469 Bytes

HITS: 1903

  1. // increaser
  2. #include <iostream>
  3. using namespace std;
  4. void increase (void* data, int psize)
  5. {
  6. if ( psize == sizeof(char) )
  7. { char* pchar; pchar=(char*)data; ++(*pchar); }
  8. else if (psize == sizeof(int) )
  9. { int* pint; pint=(int*)data; ++(*pint); }
  10. }
  11. int main ()
  12. {
  13. char a = 'x';
  14. int b = 1602;
  15. increase (&a,sizeof(a));
  16. increase (&b,sizeof(b));
  17. cout << a << ", " << b << endl;
  18. return 0;
  19. }

comments powered by Disqus