PIC18f4550 / LCD16x2 / MIKRO C
Your C compiler is old and crusty

Early C (K&amp;R) had a rule where all variable declarations in a block must come before all other statements in a block, and this rule wasn't lifted until ISO C99.  So, you need to move the declarations of x and txt above the statements before them to make things work with your compiler, which clearly predates ISO C99 (it's C90-vintage, at best).