?
Solved

how to do this like it should ??

Posted on 2005-03-28
6
Medium Priority
?
219 Views
Last Modified: 2010-04-01
Hello,

I'm starting to learn how to program in c++.
I use now
for (inti=0,i<20,i++){string[i]=0x00;}
to "reset" a string to zero.

How is the correct way to do that ?

0
Comment
Question by:lapijn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 1

Assisted Solution

by:Andrey_go
Andrey_go earned 80 total points
ID: 13642586
string[0]=0; should be enough
0
 
LVL 25

Expert Comment

by:InteractiveMind
ID: 13642598
use a char array, instead of string.

0
 
LVL 2

Assisted Solution

by:teuntje
teuntje earned 160 total points
ID: 13642627
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 160 total points
ID: 13643068
Andrey_go answer will be enough, assumming you are working with a char array (I guess it is because 'string' name), because in stardard C, all string are zero-terminated.

string[0]=0;  could be simplified to:
*string = 0;

'string' is not a good name because there is some library called STL that uses a data type called string.
0
 

Author Comment

by:lapijn
ID: 13643132
thanks teuntje.
0
 

Author Comment

by:lapijn
ID: 13643142
OK, jaime_olivares. Thanks all.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question