Q:

Programming Console Error

#include<stdio.h>
void  main()
{
    do
    {
        char i;
        FILE *f,*q;
        f=fopen("E:\\txt.txt","w");
        while((i=getchar())!='\n')
        {
            fputc(i,f);
        }
        fclose(f);
        q=fopen("E:\\txt.txt","r");
        while((i=fgetc(q)!=EOF))
        {
            printf("%c",i);
        }
    } while(1);
}

It should output what pressed from keyboard but outputs to question boxes of same length of character I entered. And text is there where I specified in correct form. Below is the output after running the program.  

A:

The placement of parentheses in this line is wrong:
while ((i = fgetc(q) != EOF)) {

Because of operator precedence (in C, assigment operators have the lowest precedence), this is equivalent to 
while (i = (fgetc(q) != EOF));

in other words, you are assigning TRUE to i each time, until you reach the end of the file. If you display that as char, you get a funny unprintable character, so you get a line of funny characters, but of the correct length.
It should be:
while ((i = fgetc(q)) != EOF) {

Then you should get your desired output.

