My Math Forum  

Go Back   My Math Forum > Science Forums > Computer Science

Computer Science Computer Science Forum


Thanks Tree1Thanks
  • 1 Post By Evgeny.Makarov
Reply
 
LinkBack Thread Tools Display Modes
May 10th, 2014, 09:52 AM   #1
Senior Member
 
Joined: Oct 2012

Posts: 460
Thanks: 0

PLEASE, which programming language is that?

Hello!

This is the code for djb2 (hash) function!
Please, can someone tall me WHICH PRORAMMING LANGUAGE IS THAT?

Sorry for very begiiner questiin!

Many thanks!!!

unsigned long
hash(unsigned char *str)
{
unsigned long hash = 5381;
int c;

while (c = *str++)
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */

return hash;
}
ungeheuer is offline  
 
May 10th, 2014, 09:57 AM   #2
Senior Member
 
Joined: Dec 2013
From: Russia

Posts: 327
Thanks: 108

Looks like C.
Thanks from ungeheuer
Evgeny.Makarov is offline  
May 10th, 2014, 10:35 AM   #3
Senior Member
 
Joined: Oct 2012

Posts: 460
Thanks: 0

Hello!

Hello!
C++ could also be?
ungeheuer is offline  
May 10th, 2014, 10:41 AM   #4
Senior Member
 
Joined: Dec 2013
From: Russia

Posts: 327
Thanks: 108

Quote:
Originally Posted by ungeheuer View Post
C++ could also be?
Could be.
Evgeny.Makarov is offline  
September 30th, 2014, 05:09 PM   #5
Newbie
 
Joined: Sep 2014
From: london

Posts: 5
Thanks: 0

agreed c or c++ most likely also might be d as well but im not sure about that!
kurtgodel is offline  
October 26th, 2014, 05:45 AM   #6
Newbie
 
Joined: Oct 2014
From: France

Posts: 2
Thanks: 0

It's either C or C++. That is to say, it could be used in both programming languages. In C++, the use of object orientation is more common and you will often see functions written as class::hash(unsigned char* str). Object orientation cannot be used in C, which is one of the main differences between the two programming languages.

Part of the program is missing (it's only the function), full program could be:

Code:
#include <stdio.h>

unsigned long
hash(unsigned char *str)
{
  unsigned long hash = 5381;
  int c;

  while (c = *str++)
    hash = ((hash << 5) + hash) + c; /* hash * 33 + c */

  return hash;
}

int main()
{
   printf("%d \n", hash("hello world") );
}
prosec is offline  
Reply

  My Math Forum > Science Forums > Computer Science

Tags
language, programming



Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Language and Geometry johnr New Users 4 September 3rd, 2013 07:02 PM
finding a language token22 Computer Science 4 September 22nd, 2012 01:00 PM
Help, this is like another language to me Redneck_country_girl Algebra 5 May 18th, 2011 11:23 PM
C Language parasio Computer Science 2 May 13th, 2009 08:33 PM
Seems Like Another Language autumnangel Algebra 1 February 22nd, 2009 03:39 PM





Copyright © 2018 My Math Forum. All rights reserved.