How to initialize a bool pointer in C? : <p>I'm coding something small to understand how pointers work and have reached an issue.
I have a boolean pointed to by "valid" in a file called "main.c":</p>

<pre><code>bool *valid;
</code></pre>

<p>The pointer's address is passed to a method in a second file called "test.c": </p>

<pre><code>method(&amp;valid);
</code></pre>

<p>Inside the "test.c" method I set valid to true:</p>

<pre><code>*valid = true;
</code></pre>

<p>After the method call in "main.c" I dereference valid in two if statements to see if it's true or false: </p>

<pre><code>if (*valid) {
    printf("valid is true.\n");
}
if (!(*valid)) {
    printf("valid is false.\n");
}
</code></pre>

<p>Both statements print, but only "valid is true" should. What could be the issue here?</p>
