IronNoob

Please login or register.

Login with username, password and session length
Advanced search  

News:

Migrated to dedicated hosting. Post any weirdness you observe in the Lounge.

Author Topic: Pointers! :D  (Read 141 times)

0 Members and 1 Guest are viewing this topic.

Void_Knight

  • Man of Mystery
  • Global Moderator
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 9602
  • Nope, Void_Knight.
    • View Profile
Pointers! :D
« on: February 24, 2013, 01:18:38 am »

So I just figured out how C++ pointers work, so exciting! :P

Code: [Select]
#include<iostream>

int main(){
   int a,b;
   int *c;
   c = &a;
   *c = 10;
   c = &b;
   *c = 100;
   std::cout << a + b << " should equal 110" << std::endl;
   return 0;
}

Man it looks confusing as hell, but I understand it now. :D
Logged

Void_Knight

  • Man of Mystery
  • Global Moderator
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 9602
  • Nope, Void_Knight.
    • View Profile
Re: Pointers! :D
« Reply #1 on: February 24, 2013, 01:55:12 am »

Oh no, horrible meme joke incoming...

Code: [Select]
#include <iostream>
#include <string>
using namespace std;

void increase(void* data, int psize)
{
if (psize == sizeof(char)) {
char* pchar;
pchar = (char*) data;
++(*pchar);
}else if (psize == sizeof(int)){
int* pint;
pint = (int*) data;
++(*pint);
}
}
int main(){
        int powerlevel = 9000;
        increase(&powerlevel,sizeof(powerlevel));
        string answer = (powerlevel >= 9001) ? "It's over 9000!" : "Nope.avi";
        cout << "Vegeta, what does the scouter say about his power level? \n " << answer << endl;
}
« Last Edit: March 10, 2013, 01:09:00 pm by cowbear16 »
Logged

jamjam195

  • RBX Spec Ops
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 9288
  • Why, hello there.
    • View Profile
    • Bobstudios
Re: Pointers! :D
« Reply #2 on: February 24, 2013, 04:06:20 am »

wat? Pointers as in cursors or the popup when you hover over something?
Logged
Why Hello There.

Alternative: Wopian
Bobstudios | WPM: 81 | World of Wopian

xzbobzx

  • RBX Spec Ops
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 8836
  • ಠ_ಠ
    • View Profile
    • Bobstudios.org
Re: Pointers! :D
« Reply #3 on: February 24, 2013, 05:24:28 am »

wat? Pointers as in cursors or the popup when you hover over something?

lol'd
Logged


Vergil the Drippy Dragon

  • Newbie
  • *
  • Offline Offline
  • Posts: 1
    • View Profile
Re: Pointers! :D
« Reply #4 on: March 09, 2013, 05:03:05 pm »

wat? Pointers as in cursors or the popup when you hover over something?
you amaze me
Logged
 

Page created in 0.071 seconds with 21 queries.