Block Sum Check

This is a discussion on Block Sum Check within the C++ Programming forums, part of the General Programming Boards category; It's probably easy for most of you but ... is there and easy way to get a BSC from a ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,335
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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,159
    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,159
    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, 03: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-15-2002, 11:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21