Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

TheOne1

cin.ignore()

This topic is 5261 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

cin.ignore( 256, ''\n'' ) what do the numbers mean in the parameters? Ignore the first 256 characters? Or is 256 representing the char/symbol values?

Share this post


Link to post
Share on other sites
Advertisement
MSDN is your friend

Anyway, it means to ignore the next 256 characters, or only up to the next newline (inclusive), whichever comes first.

Share this post


Link to post
Share on other sites
one more question...

can arrays be deleted without being a class private member variable?

for example, can i do this:

char sName[ 50 ];
....
...
...
...
delete [ ] sName; // i think thats how you delete

[edited by - TheOne1 on May 28, 2004 12:04:57 AM]

Share this post


Link to post
Share on other sites
Yes. If an array was created with new then it must be deleted with delete.


char *some_stuff = new char[300];

//use some_stuff


//Free the memory that some_stuff points to

delete [] some_stuff;


NB: brackets are used after delete only when you use brackets when you use new. Compare with the above

   
char *a_char = new char;

//use a_char


//Free the memory that a_char points to

delete a_char;


You do NOT delete arrays that were not created with new. In your example sName is created on the stack and is automatically freed when it goes out of scope.


Thanks Salsa!Colin Jeanne | Invader's Realm
"I forgot I had the Scroll Lock key until a few weeks ago when some asshole program used it. It even used it right" - Conner McCloud

[edited by - Invader X on May 28, 2004 12:16:38 AM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!