Q: What is wrong with my for loop? It turns 2 times when I enter only 1 input in a letter guessing game in C I know this code is not completed yet, but I cannot go any further because of this issue.
If you execute the code with any compiler you will see it. 
After the instructions gets written at console, when you enter a word, loop takes 2 turns. It reduces chance 2 times too when it's supposed to be 1. Why is that?
I am using devc++ and windows.
#include<stdio.h>
#include<stdlib.h>

int main(){     
    int i,j,totalTrial=6,currentTrial=0;
    char myWord [6]={'d','o','c','t','o','r'};
    char lineArray [6]={'-','-','-','-','-','-'};
    char guess;     

    printf("Hello,this is a simple word-guessing game. Try to find my secret word. You have 6 chances.");

    printf("Lets begin!!\n");

    printf("Word:\n------\n");

    for(i=0;i<=6;i++)
    {
        printf("\nGuess a letter: ");
        scanf("%c",&guess);

            for(j=0;j<7;j++)
            {

                if(guess==myWord[j])
                {
                lineArray[j]=guess;
                }
            }

        currentTrial++;
        printf("\nResult: %s, %d hakkin kaldi.\n",lineArray,totalTrial-currentTrial);           
    }       

    getch();
    return 0;
}


A: This is happening because the scanf() is reading the stray \n (newline character) from the input buffer. [When you are giving input, you must be entering a character followed by ENTER key.]
To resolve this, add a space before % character in scanf() like this:
scanf(" %c", &guess);

This will skip the leading whitespace characters (including newline character) and read the input given by the user.

A: With regard to the line:
scanf("%c",&guess);

How many characters do you think are turning up when you enter, for example, dENTER? I'll give you a hint, it isn't one :-)
The problem is that your scanf will read each character in turn and process it, including the newline generated when you hit ENTER.
A better solution would be to use a more complete input solution such as this one here.
It will handle many scenarios that a simple method based on scanf or getchar.
