#include<iostream>
#include<string.h>
int main()
{
char* str="my name"; /*plz explain what is pointer-name,and what is string-
name here(realy confused) ? i am new to pointers :) */
int len=strlen(str);
char* ptr;
ptr=new char[len+1]; /*is this ptr pointer or string*/
strcpy(ptr,str);
cout<<ptr;
delete ptr; /*how this works */
cout<<endl<<ptr; /*this 'ptr' should be destroyed as effect of "delete ptr"
,but still displaying here when executed*/
return 0;
}
saransh60 0 Newbie Poster
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster
Kanoisa 52 Posting Whiz in Training
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster
Kanoisa 52 Posting Whiz in Training
Fbody 682 Posting Maven Featured Poster
saransh60 0 Newbie Poster
Aranarth 126 Posting Whiz in Training
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster
saransh60 0 Newbie Poster
Aranarth 126 Posting Whiz in Training
Fbody 682 Posting Maven Featured Poster
Aranarth 126 Posting Whiz in Training
Fbody 682 Posting Maven Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.