nazzie's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
Members
Active Posts:
39 (0.06 per day)
Joined:
31-July 12
Profile Views:
1,799
Last Active:
User is offline Nov 20 2012 04:09 AM
Currently:
Offline

Previous Fields

Country:
Who Cares
OS Preference:
Who Cares
Favorite Browser:
Who Cares
Favorite Processor:
Who Cares
Favorite Gaming Platform:
PC
Your Car:
Who Cares
Dream Kudos:
0
Icon   nazzie has not set their status

Posts I've Made

  1. In Topic: Converting a binary number 0 to 99 into a two digit BCD number

    Posted 1 Sep 2012

    I did the necessary changes as you've have suggested but I still get an error message on Scanf.

    Is there a difference if you use unsigned over uint? Thanks :)

    Quote

    warning #2234: Argument 2 to 'scanf' does not match the format string; expected 'unsigned char *' but found 'int'.
    error #2060: Invalid return type; expected 'unsigned char' but found 'unsigned char __cdecl (*)(unsigned char)'.


    #include <stdio.h>
    #include <conio.h>
    #include <stdlib.h>
    #include <stdint.h>
    #include <inttypes.h>
    
    //! Converts a binary number 0 to 99 into a two digit BCD number
    uint8_t BinBcdB( uint8_t ubBIN );
    
    
    int bit_patterns[] = {0,1,2,3,4,5,6,7,8,9};
    char*representation[] = {
      "0000","0001","0010","0011","0100","0101","0110","0111","1000","1001"
    };
    
    
    	
    int main(void)
    {
    	
      BinBcdB( 0001 );
    
    }
    
    uint8_t BinBcdB( uint8_t ubBIN )
    {
    	uint8_t i;
    	uint8_t temp;
    	char*F[100];
      	
    	printf("enter number: \0");
    	scanf("%"SCNu8, temp);
      	if ((1 !=temp) || (temp <= 0))
             { fputs("test fail",stderr);
               return EXIT_FAILURE;
             }
             
      	for (i = 99; temp; --i, temp /= 10)
       	 F[i] = representation[temp%10];
      	for (++i; i < 100; ++i)
        fputs(F[i],stdout);
     	   
      	getchar();
      return BinBcdB;	
    }
    
    
  2. In Topic: Converting a binary number 0 to 99 into a two digit BCD number

    Posted 29 Aug 2012

    I took out scanf for a hardcoded test run and it give me a warning message

    Quote

    Building main.obj.
    error #2157: Unrecognized statement.
    error #2001: Syntax error: expected ';' but found '('.
    error #2001: Syntax error: expected ';' but found ')'.
    error #2061: Invalid statement termination.
    *** Error code: 1 ***
    Done.


    How come it says unrecognized statement for
    	if ((1 !=temp)) || (temp <= 0))
    



    #include <stdio.h>
    #include <conio.h>
    #include <stdlib.h>
    #include <stdint.h>
    #include <inttypes.h>

    //! Converts a binary number 0 to 99 into a two digit BCD number
    uint8_t BinBcdB( uint8_t ubBIN );


    int bit_patterns[] = {0,1,2,3,4,5,6,7,8,9};
    char*representation[] = {
    "0000","0001","0010","0011","0100","0101","0110","0111","1000","1001"
    };



    int main(void)
    {
    //	uint8_t TestBinary;
    
    	BinBcdB(0001);
    	return 0;
    }
    
    
    uint8_t BinBcdB( uint8_t ubBIN ){
    	uint8_t i, temp;
    	char*F[100];
      	
    	printf("enter number:\0", temp);
      	if ((1 !=temp)) || (temp <= 0))
             { fputs("test fail",stderr);
               return EXIT_FAILURE;
             }
             
      	for (i = 99; temp; --i, temp /= 10)
       	 F[i] = representation[ubBIN%10];
      	for (++i; i < 100; ++i)
        fputs(F[i],stdout);
     	//printf("BCD: ", F[i]);
        
      	getchar();
      return temp;	
    }
    
    
    
    
  3. In Topic: Converting a binary number 0 to 99 into a two digit BCD number

    Posted 29 Aug 2012

    sorry i only need to use uint8_t in the function given to me. I'll download Pelles C and see what happens. Thanks!
  4. In Topic: Converting a binary number 0 to 99 into a two digit BCD number

    Posted 29 Aug 2012

    It's something like this code..

    uint8_t BinBcdB(uint8_t ubBin);
    uint8_t BinBcdB2(uint8_t ubBin2);
    
    
    int bit_patterns[] = {0,1,2,3,4,5,6,7,8,9};
    char*Bcd1[] = {"0000","0001","0010","0011","0100","0101","0110","0111","1000","1001"};
    char*Bcd2[] = {"0000","0001","0010","0011","0100","0101","0110","0111","1000","1001"};
    
      
    
    int main()
    {	//uint8_t 0001;
    	uint8_t Binary, bcd1, bcd2;
    	
    	printf("Enter Binary number to be converted to BCD \n", Binary);
    	scanf("%"SCNu8, Binary);
    		BinBcdB(uint8_t ubBin);
    		BinBcdB2(uint8_t ubBin2);
    	 printf("you have entered Binary" %u 2 Digit BCD : "%"PRIu8,Bcd1 "%"PRIu8, Bcd2);
    	
    	getch();
    	return 0;
    }
    
    
    
    
    uint8_t BinBcdB(uint8_t ubBin)
    {	
    	uint8_t i,temp;
    	char*F1[100];
    	
    	for (i = 99; temp; --i, temp /= 10)
     	   F1[i] = Bcd1[temp%10];
     	   for (++i; i < 100; ++i)
    	
    	printf("%"PRIu8,Bcd1);
        return 0;
    }
    
    uint8_t BinBcdB2(uint8_t ubBin2)
    {	
    	uint8_t i,temp2;
    	char*F2[100];
    	
    	for (i = 99; temp2; --i, temp2 /= 10)
     	F2[i] = Bcd2[temp2%10];
     	   for (++i; i < 100; ++i)
    	printf("%"PRIu8, Bcd2);
    	return 0;
    }
    
    
    


    can I have the 2 output bcd in printf using the PRIu8? :)
     printf("you have entered Binary" %u 2 Digit BCD : "%"PRIu8,Bcd1 "%"PRIu8, Bcd2);
    
  5. In Topic: Converting a binary number 0 to 99 into a two digit BCD number

    Posted 28 Aug 2012

    Oh! let me try that.
    it would look like this?

       printf("Enter Binary number to be converted to BCD ");
    	scanf("%"SCNu16,&temp\0);
    

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

nazzie hasn't added any friends yet.

Comments

nazzie has no profile comments yet. Why not say hello?