I've got to write a program where it replaces a letter with a dash and then asks the user to enter the letter that should be their. I've written a program and It works the first time around and then prints out two lines.
Where have I gone wrong ??
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
#include<time.h>
int main()
{
char array[][10]= {"sam", "ben", "sally", "molly", "jake", "samuel", "table", "chair", "computer", "mouse"};
char answer;
char input;
int r1=0;
int r2=0;
int length=0;
int loop=0;
int loop2=0;
int score=0;
srand (time(NULL));
for (loop=0;loop!=10;loop++)
{
r1 = rand() %9;
length = strlen(array[r1]);
r2 = rand() %length;
answer=array[r1][r2];
printf("Type the missing letter of word %d\n",loop);
for (loop2=0;loop2!=r2;loop2++)
{
printf("%c",array[r1][loop2]);
}
printf("-");
while(loop2!=length)
{
printf("%c",array[r1][loop2+1]);
loop2++;
}
if(loop2==length)
{
scanf("%c",&input);
if (input==answer) score++;
else score--;
}
}
printf("your score is %d",score);
system("pause");
}