Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: C++, pointers problem!  (Read 3190 times)

0 Members and 1 Guest are viewing this topic.
C++, pointers problem!
« on: April 12, 2006, 04:18:48 pm »
  • Its the joeshmo!
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 694
Code: [Select]
#include<iostream>;
int main() {
int ted,beth,j;
j=25;
ted=&j;
beth=*ted;
}
It might be just my compiler, which is bloodshed dev-C++, but pointers dont work! It gives me the error:
Quote
invalid conversion from int to into
Help me please!
« Last Edit: February 28, 2007, 09:59:27 pm by 4Sword »
Logged
  • Netterra Virtual Pets
Re: C++, pointers problem!
« Reply #1 on: April 12, 2006, 04:26:07 pm »
  • Its the joeshmo!
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 694
Nevermind, I fixed the problem myself. When declaring a pointer it must have a * before it.
Fixed code:
Code: [Select]
#include<iostream>
int main() {
int * ted;
int beth,j;
j=25;
ted=&j;
beth=*ted;
}
Also I forgot that ; is not needed for the include statement.
Logged
  • Netterra Virtual Pets

aab

^ Evolved from a Hobbit
Re: C++, pointers problem!
« Reply #2 on: April 12, 2006, 04:33:36 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 992
Just mentioning, you can go:  int beth,j,*ted;.
When '*' is used for pointers, you can literally read it as 'whats at the address of', so int * p; would mean int is whats at the address of p;
Logged




I ♥ Sol
.... I ♥ Sol ? wtf how long has that been there? >_> *rrrrrrrrar*
  • MySpace
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.038 seconds with 44 queries.

anything