We are given
\[
\tan^2x=1.
\]
Taking square root on both sides:
\[
\tan x=\pm 1.
\]
Now,
\[
\tan x=1
\]
when
\[
x=\frac{\pi}{4}.
\]
The general solution of
\[
\tan x=1
\]
is
\[
x=n\pi+\frac{\pi}{4}.
\]
Also,
\[
\tan x=-1
\]
when
\[
x=-\frac{\pi}{4}.
\]
The general solution of
\[
\tan x=-1
\]
is
\[
x=n\pi-\frac{\pi}{4}.
\]
Combining both cases:
\[
x=n\pi\pm\frac{\pi}{4}.
\]
Therefore, the general solution is
\[
n\pi\pm\frac{\pi}{4}.
\]