This is a discussion on Simple enough task within the C Programming forums, part of the General Programming Boards category; you have declared i twice...

1. you have declared i twice

2. cool, sorted that.
Just the end of file thing now.

Its quite strange, when I click the error its going right to the top of the code, inside the #include<stdio.h> line.

I'm sure this is just something silly but any ideas?

Code:
#include <stdio.h>
#include <string.h>
#include <math.h>

int main()
{

int codeword_array[20];
int i=0;
int bit;

printf("Welcome to the 5-bit parity code calculator\nPlease enter the 1st bit of the 15 bit codeword now: \n");

for ( i = 0; i<16; i++)
{
scanf("%d", &bit);
if (bit != 0 && bit !=1)
{
printf("All bits must be a 0 or a 1/n");
}
else
{
codeword_array[i] = bit;
}

if (codeword_array[0] + codeword_array[5] + codeword_array[10] == (0||2))
{
codeword_array[15] = 0;
}
else if (codeword_array[0] + codeword_array[5] + codeword_array[10] == (1||3))
{
codeword_array[15] = 1;
}
else
{
printf("Error\n");
}

system("pause");
return 0;
}

3. What is the error?

4. (46) : fatal error C1075: end of file found before the left brace '{' at 'c:\users\niall\documents\college\4th year\2nd semester\ee402\5bit parity code\5bit parity code\source.c(6)' was matched

5. Originally Posted by niallheavey
(46) : fatal error C1075: end of file found before the left brace '{' at 'c:\users\niall\documents\college\4th year\2nd semester\ee402\5bit parity code\5bit parity code\source.c(6)' was matched
Are you surprised by that, given that you have seven opening braces and six closing braces?

6. You need another close bracket at the end. you never close the for loop bracket

7. I knew it was going to be something stupid.

Thank you very much for all the help.
Regards,

Niall.

Page 2 of 2 First 12