6. $[x]$ represents the greatest integer not exceeding the real number $x$. Let $N$ be a positive integer. Then the number of all solutions to the equation $x^{2}-\left[x^{2}\right]=(x-[x])^{2}$ in the interval $1 \leqslant x \leqslant N$ is ( ).
(A) $N^{2}+N+1$
(B) $N^{2}-N$
(C) $N^{2}-N+1$
(D) $N^{2}-N+2$
6.C.

Obviously, $x=N$ is a solution to the equation.
Suppose $1 \leqslant x < N, m = [x]$,
$$
p = x - m = \{x\}.
$$

Then $x = m + p$.
The original equation becomes $(m + p)^2 - [(m + p)^2] = p^2$, which simplifies to $2mp = [2mp + p^2]$.
Since $0 \leqslant p < 1$ and $2mp$ is an integer, then $p = 0, \frac{1}{2m}, \frac{2}{2m}, \cdots, \frac{2m-1}{2m}$, giving a total of $2m$ values.
Because $m = 1, 2, \cdots, N-1$, the total number of such numbers is $2 + 4 + 6 + \cdots + 2(N-1) = N^2 - N$.

Therefore, the number of all solutions to the equation $x^2 - [x^2] = (x - [x])^2$ in the interval $1 \leqslant x \leqslant N$ is $N^2 - N + 1$.