Click here to Skip to main content
15,892,674 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to declare global variable in MFC dialog based application? Pin
CPallini23-Oct-08 6:06
mveCPallini23-Oct-08 6:06 
GeneralRe: How to declare global variable in MFC dialog based application? Pin
sn00pi23-Oct-08 8:02
sn00pi23-Oct-08 8:02 
GeneralRe: How to declare global variable in MFC dialog based application? Pin
CPallini23-Oct-08 8:06
mveCPallini23-Oct-08 8:06 
Questionstring pointer and int pointer Pin
rahulcrjk23-Oct-08 2:40
rahulcrjk23-Oct-08 2:40 
AnswerRe: string pointer and int pointer Pin
Roger Stoltz23-Oct-08 2:52
Roger Stoltz23-Oct-08 2:52 
AnswerRe: string pointer and int pointer Pin
Cedric Moonen23-Oct-08 2:55
Cedric Moonen23-Oct-08 2:55 
AnswerRe: string pointer and int pointer Pin
CPallini23-Oct-08 3:01
mveCPallini23-Oct-08 3:01 
AnswerRe: string pointer and int pointer Pin
king'ori23-Oct-08 4:03
king'ori23-Oct-08 4:03 
hoo ho, i get your question right, and you have no idea how i struggled with c++ before i coluds understand pointers, thats why they even made java, to eliminate the whole thing about pointers, but the minute you understand the, thats it..

Just know that pointers yes have 2 major refences or usage in c++.
It all depends on how you use them, but fact is , they do point to an address in memory, not the actual data.

Your question goes like this,
if i say
int my_number = 5;
int* my_pointer = #

the output ;
cout << my_pointer ; displays an address, sth like 45542945;

if i output ;
cout << *my_pointer; then i get the number 5;
this is to say, my_pointer, is a memory (RAM) address, and the value in *my_pointer is the value 5;

if when used with a character / string, the pointer will refence the address of the first character, then when i say
char* my_ptr = "this is a string";
cout <<my_ptr.
my pointer being an address of the 1st character, then i shoudl see the address output, not the whole string.
but thats not the case, why??? was that the question.

okay, one point you have right, the other point you are missing is that, a pointer when used to refence an array, it points to the first element of the array.

why do you think this is correct;

int nums[3] = {11,21,31};

int* nums_ptr = nums;

cout<< nums_ptr[0] ;

because when you do point an array (a string is a also an array), you can copy the whole array into a pointer one time.
and yuo know that an array is placed in (contigous) continuous memory locations, i.e. if 11 is in addres x, then 21 is in x+1, and 31.

so for integers if you want the third element of the array in that has been copied to an pointer, if you say nums_ptr[2], you wont get the address of the 3rd element, you'll get the value.
but again for integers if you say
cout<<nums_ptr;

you wont get all the elements of the array displayed on the screen like 112131, no, you get the address.
thats the only differents with characters since, an array of characters is treated like a string..
displaying the pointer wont display the adress of the fisrt character but the whole string.

try play with pointers, that's the weak and stronghold with c++, in that learning is abit confusing but once learnt it gives some crazy flexibility you wont get from any of it's neighbors..
QuestionConfiguration Reload Pin
Soumyadipta23-Oct-08 2:03
Soumyadipta23-Oct-08 2:03 
AnswerRe: Configuration Reload Pin
Roger Stoltz23-Oct-08 2:20
Roger Stoltz23-Oct-08 2:20 
QuestionHow Can I Return Directory to Output? Pin
Member 422782623-Oct-08 0:37
Member 422782623-Oct-08 0:37 
AnswerRe: How Can I Return Directory to Output? Pin
CPallini23-Oct-08 2:24
mveCPallini23-Oct-08 2:24 
QuestionCreating COM by using ATL dll to wrap C++ MFC unmanaged dll Pin
Member 348023223-Oct-08 0:31
Member 348023223-Oct-08 0:31 
AnswerRe: Creating COM by using ATL dll to wrap C++ MFC unmanaged dll Pin
Roger Stoltz23-Oct-08 1:32
Roger Stoltz23-Oct-08 1:32 
GeneralRe: Creating COM by using ATL dll to wrap C++ MFC unmanaged dll Pin
Member 348023223-Oct-08 7:26
Member 348023223-Oct-08 7:26 
Question[Message Deleted] Pin
Pearson_Bee22-Oct-08 23:49
Pearson_Bee22-Oct-08 23:49 
AnswerRe: something about recv() function confuse me Pin
CPallini22-Oct-08 23:58
mveCPallini22-Oct-08 23:58 
GeneralRe: something about recv() function confuse me Pin
Pearson_Bee23-Oct-08 0:19
Pearson_Bee23-Oct-08 0:19 
GeneralRe: something about recv() function confuse me Pin
CPallini23-Oct-08 1:01
mveCPallini23-Oct-08 1:01 
GeneralRe: something about recv() function confuse me Pin
Mark Salsbery23-Oct-08 4:18
Mark Salsbery23-Oct-08 4:18 
RantRe: [Message Deleted] Pin
JudyL_MD23-Oct-08 9:30
JudyL_MD23-Oct-08 9:30 
QuestionPlease Help me !! Pin
Le@rner22-Oct-08 22:10
Le@rner22-Oct-08 22:10 
AnswerRe: Please Help me !! Pin
Roger Stoltz22-Oct-08 22:17
Roger Stoltz22-Oct-08 22:17 
GeneralRe: Please Help me !! Pin
Le@rner22-Oct-08 22:25
Le@rner22-Oct-08 22:25 
AnswerRe: Please Help me !! Pin
Roger Stoltz22-Oct-08 22:32
Roger Stoltz22-Oct-08 22:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.