Thread: Simple enough task

  1. #16
    Registered User
    Join Date
    Feb 2009
    Posts
    278
    you have declared i twice

  2. #17
    Registered User
    Join Date
    Feb 2009
    Location
    Dublin Ireland
    Posts
    10
    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. #18
    Registered User
    Join Date
    Feb 2009
    Posts
    278
    What is the error?

  4. #19
    Registered User
    Join Date
    Feb 2009
    Location
    Dublin Ireland
    Posts
    10
    (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. #20
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by niallheavey View Post
    (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. #21
    Registered User
    Join Date
    Feb 2009
    Posts
    278
    You need another close bracket at the end. you never close the for loop bracket

  7. #22
    Registered User
    Join Date
    Feb 2009
    Location
    Dublin Ireland
    Posts
    10
    I knew it was going to be something stupid.

    Thank you very much for all the help.
    Regards,

    Niall.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 12-31-2007, 11:40 AM
  2. Where do a task get "wakeuped", blocked, preempted?
    By micke_b in forum Linux Programming
    Replies: 4
    Last Post: 12-28-2007, 04:49 PM
  3. Simple message encryption
    By Vicious in forum C++ Programming
    Replies: 10
    Last Post: 11-07-2004, 11:48 PM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. Help with simple physics task
    By Zewu in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 04-23-2004, 02:22 PM

Tags for this Thread