ZFGC

Projects => Discussion => Topic started by: joeshmo on April 12, 2006, 04:18:48 pm

Title: C++, pointers problem!
Post by: joeshmo on April 12, 2006, 04:18:48 pm
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!
Title: Re: C++, pointers problem!
Post by: joeshmo on April 12, 2006, 04:26:07 pm
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.
Title: Re: C++, pointers problem!
Post by: aab on April 12, 2006, 04:33:36 pm
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;

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