Hey guys.. I'm hoping for some clarification on this situation i created.
i was playing around with pointers and this situation came up.
(please forgive me if im just being absent minded and it's a syntax error.)
the above code does just as expected and outputs "abcd"Code:char* b_stringp; b_stringp = "abcd"; cout << b_stringp << endl;
then i tried to do a similar thing with a int
im a little confused as to why this code didn't work?? it seems to have the same logic as the previous code.Code:int* b_int; b_int = 234; cout << b_int << endl;
then i thought to fix this problem would be to dynamically allocate memory.
and realized i had to put an astrix infrontCode:int* a_int; a_int = new int; a_int = 234; cout << a_int << endl;
this code tho did work
from my understading this actualy makes a pointer that points to a area of memory labeled 234.Code:int* a_int = new int; *a_int = 234; cout << *a_int << endl;
anyways i was hoping someone could clarify the above for me.. also show me how to properly make an int * and on another line dynamically allocate memory to it. and then insert data into it and "cout" it.. hope i can get some clarifying here