i want to clear a string after the prog. has done it`s work.
i tried it by using a for loop and assigning a blank, but it didn`t work.
the problem is that if i run the program again then the earlier value is displayed again .
i`m using Turbo c++.

Recommended Answers

All 5 Replies

Assign the first element a '\0'. If you're a masochist, use memset on the whole char array.

not working

post code. or not helping.

char array="food";
You can use delete[]array to clear the memory

No you can't. You can only 'delete' or 'free' dynamically allocated memory. Plus the above statement won't compile. Go figure.

And please see the date of the previous post before posting in a thread. This thread is 3 years old.

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.