Isnt this how I would dereferrence a pointer
and to assign the value in num to iCode:int *num; ... ... int i; i = #
Code:i = **num;
Isnt this how I would dereferrence a pointer
and to assign the value in num to iCode:int *num; ... ... int i; i = #
Code:i = **num;
Last edited by sweets; 11-16-2004 at 07:20 PM.
simple is always an understatement.....
An example:
Code:int* p = new int; *p = 3; // Assign 3 to the space pointed to by p int num = *p; // num == 3 now or... int num = 3; int* p = # // p now points to num
The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.
no, it would be
Code:int *num; ... ... int i = 5; num = &i; ... ... int x = *num; //to assign value POINTED TO by num to x
Just Google It. √
(\ /)
( . .)
c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.
No, it's like this
andCode:int *num; int i; //The memory adress of i is stored in num. num = &i;Code://The memory contents pointed by num are dereferenced ONCE and placed in i i = *num;
//EDIT: UH!! fast posters
What about :
where val is a variable within a classCode:int *num; int i; num.val=10; i=num.val;
simple is always an understatement.....
a) num is a pointer to an int
b) the syntax is wrong
Code:struct foo { int val; }; int main() { foo* bar = new foo; bar->val = 2; (*bar).val = 3; delete bar; }
The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.
No!
num is a pointer to an INT.
Could be
//edit: post beated again!Code:class Int{ int val; Int(int n=0) : val(n){} }; Int num; int i; num.val=10; i=num.val;
Last edited by xErath; 11-16-2004 at 08:52 PM.
Originally Posted by xErathWhat are we debating about?Originally Posted by Zach L.
- Stack Overflow
Segmentation Fault: I am an error in which a running program attempts to access memory not allocated to it and core dumps with a segmentation violation error. This is often caused by improper usage of pointers, attempts to access a non-existent or read-only physical memory address, re-use of memory if freed within the same scope, de-referencing a null pointer, or (in C) inadvertently using a non-pointer variable as a pointer.
Check the times. They posted simultaneously.
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
Ah, thanks; just noticed.
I'll keep my eye on post times in the future. It may be the key to the answer
- Stack Overflow
Segmentation Fault: I am an error in which a running program attempts to access memory not allocated to it and core dumps with a segmentation violation error. This is often caused by improper usage of pointers, attempts to access a non-existent or read-only physical memory address, re-use of memory if freed within the same scope, de-referencing a null pointer, or (in C) inadvertently using a non-pointer variable as a pointer.