Thread: Block Sum Check

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    11

    Block Sum Check

    It's probably easy for most of you but ... is there and easy way to get a BSC from a char array ... ex.: char buffer[20]; ?

    thank you !

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    You mean like using a for loop to subscript the elements of your array?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Mar 2011
    Posts
    11
    If I understand the explanations, I have to loop and do an addition with the binary value of each char (on the client side and on the server side). Then I'll know if this is the same exact value.

    ex:

    a[0] = 'A';
    a[1] = 'B';
    a[2] = 'C';
    a[3] = 'D';
    a[4] = 'E';
    a[5] = 'F';


    A + B + C + D + E + F = something

    Any way to do this ?
    Last edited by trooper; 03-28-2011 at 12:52 PM.

  4. #4
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    Code:
    int sum = 0;
    for(int i = 0;i < 6;++i)
      sum += a[i];
    You mean like that?
    If you understand what you're doing, you're not learning anything.

  5. #5
    Registered User
    Join Date
    Mar 2011
    Posts
    11
    Humm if we can add char value into an int, I'll try this ... thanks

  6. #6
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    A char value is just a small (1 byte) data type. The character representation (e.g. 'A' or 'B') is just a convenience for the programmer. The character constants just map to the underlying character set which translates it into a value.

    Check out: www.asciitable.com
    If you understand what you're doing, you're not learning anything.

  7. #7
    Registered User
    Join Date
    Mar 2011
    Posts
    11
    I think that the formula as was looking for looks like ...

    BSC = 0;
    BSC ^= a[0];
    BSC ^= a[1];
    .
    .
    .
    .
    .
    then i will need to get a string out of BSC

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BN_CLICKED, change button style
    By bennyandthejets in forum Windows Programming
    Replies: 13
    Last Post: 07-05-2010, 11:42 PM
  2. Compiling C in Visual Studio 2005
    By emanresu in forum C Programming
    Replies: 3
    Last Post: 11-16-2009, 04:25 AM
  3. My memory management solution
    By cboard_member in forum Game Programming
    Replies: 20
    Last Post: 08-23-2006, 09:07 AM
  4. Manipulating the Windows Clipboard
    By Johno in forum Windows Programming
    Replies: 2
    Last Post: 10-01-2002, 09:37 AM
  5. Replies: 4
    Last Post: 01-16-2002, 12:04 AM