For loop and Null 0

So im writing a For loop to read a string letter by letter, and I want it to stop at the Null 0. How would I do this? Right now it just reads 20 chars.

1
2
3
4
5
6
7
8
9
10
11
12
 void encrypt(char *str, int places, FILE *fout)

{
    char i, sum;

    fprintf(fout, " %d", places);

    for(i=0; i < 20; i++)
    {
        fprintf(fout, " %c", str[i]+places);
    }
}
The for-loops syntax has (init; cond; incr) and the loop iterates as long as the cond is true. In other words, the loop stops when the cond is false. Is this a sufficient hint?


PS. What if the str and/or the fout is null? Then dereferencing them would be an error.
Topic archived. No new replies allowed.