Question: I evaluated the integral as follow, $$\int\_0^\pi \cos^3x dx=\int\_0^\pi(1-\sin^2x)\cos xdx$$
Here I used the substitution $u=\sin x$ and $du=\cos x dx$ and for $x\in [0,\pi]$ we have $\sin x\in [0,1]$ Hence the integral is,
$$\int\_0^11-u^2du=u-\frac{u^3}3\large\vert ^1\_0=\small\frac23$$But the answer I got is wrong since if I evaluate the indefinite integral $\int \cos^3x dx$ I get $\sin x-\dfrac{\sin^3x}{3}$ and now if I apply the interval $[0,\pi]$ I get $\int\_0^\pi \cos^3x dx=0$.

My question is why I got the wrong value in my approach and how to fix it?

Answer: 
The substitution rule can only be applied if the substitution is by a monotonous function. This is not the case for the sine on $[0,\pi]$. You would have to split the domain and apply the substitution rule separately on the intervals $[0,\frac\pi2]$ and $[\frac\pi2,\pi]$.

In the other way you computed the primitive or anti-derivative and then applied the fundamental theorem of infinitesimal calculus. In this case there are no restrictions by monotonicity.
Else Use $\int\_{0}^a f(x) dx=\int\_{0}^a f(a-x) dx$

$I=\int\_{0}^{\pi} \cos^3x~ dx=-I \implies 2I =0 \implies I=0$