Welcome. First, be sure your code is neatly formatted and indented - something like this:
Code:
#include <stdio.h>
int main()
{
int i=0;
char str[8];
printf("Enter 3 characters:\n");
scanf("%s", &str[10]);
if(i==0)
{
printf("You Lose\n");
}
else
printf("You Win\n");
}
This is wrong:
Code:
scanf("%s", &str[10]);
You're passing the address of a non-existent element of your array. You need to pass the address of the first element, &str[0], but since an array name by itself acts as a pointer to its first element in certain contexts, this can be simplified to str.
Also, that "scanf" call is potentially dangerous since it is capable of reading and attempting to store more characters than will fit in your array. You can limit the input by including the maximum number of characters in the format string thusly: scanf("%7s", ...). Using "fgets" would be an even better way to read a string.
To determine how many characters were entered, look into the functions in "string.h".
If you do not actually need to remember the characters that were entered, you can avoid using arrays and string functions altogether.