Mystery for loop

May 13, 2016 at 8:53am
Hi all,

I found this piece of code in my notes and I have no idea why its there or what it does. I was hoping someone can shed some light on it for me.

Thanks

stringone[20]

for (int i = 0; i < 20; i++)
{
stringone[i] = '\0';
}

May 13, 2016 at 9:24am
I am assuming this is the code :
Well, did you mean
char stringone[20]
The loop goes through all the chars in array and replaces them with the null character one by one.
Last edited on May 13, 2016 at 9:26am
May 14, 2016 at 12:39pm
You would assume correctly.

Thanks
Topic archived. No new replies allowed.