enter value for coding

some where in main:

char value;
char* sname;
sname= new char[20];
for(int i=0;i!=19;i++)
{
cin>>value;
sname[i]=value;
}


I need a stopping case when user press enter array get closed and add '\0' at the end but how to do that?
if you want to detect an enter then there are better ways to do that

you could
1
2
string name;
getline( cin, name );


or

1
2
char name[200];
gets( name );


'\0' are automatically added with these methods
Topic archived. No new replies allowed.