Hi there,
I'm not very good at c and I was wondering if anyone could give
me a hand converting the following code snippet to c# ...
BYTE checksum(BYTE *InStr, BYTE len)
{
BYTE i, sum = 0;
for (i = 0; i < len; ++i) {
sum += InStr[i];
if (sum & 0x80) {
sum &= 0x7F;
++sum;
}
}
sum = ~sum;
sum &= 0x7F;
if (sum == 0)
sum = 0x7F;
return (sum);
}
Thanks a million !!! 4 1654
Just change 'BYTE' to 'byte', 'BYTE*' to byte[], remove 'BYTE len' from
the function declaration, and change 'len' to InStr.Length. Everything
else stays the same.
-mdb ci****@insero-technologies.com (Ciaran) wrote in
news:f4*************************@posting.google.co m: Hi there,
I'm not very good at c and I was wondering if anyone could give me a hand converting the following code snippet to c# ...
BYTE checksum(BYTE *InStr, BYTE len) {
BYTE i, sum = 0;
for (i = 0; i < len; ++i) {
sum += InStr[i];
if (sum & 0x80) {
sum &= 0x7F;
++sum;
}
}
sum = ~sum; sum &= 0x7F;
if (sum == 0) sum = 0x7F;
return (sum);
}
Thanks a million !!!
Just change 'BYTE' to 'byte', 'BYTE*' to byte[], remove 'BYTE len' from
the function declaration, and change 'len' to InStr.Length. Everything
else stays the same.
-mdb ci****@insero-technologies.com (Ciaran) wrote in
news:f4*************************@posting.google.co m: Hi there,
I'm not very good at c and I was wondering if anyone could give me a hand converting the following code snippet to c# ...
BYTE checksum(BYTE *InStr, BYTE len) {
BYTE i, sum = 0;
for (i = 0; i < len; ++i) {
sum += InStr[i];
if (sum & 0x80) {
sum &= 0x7F;
++sum;
}
}
sum = ~sum; sum &= 0x7F;
if (sum == 0) sum = 0x7F;
return (sum);
}
Thanks a million !!!
I did not cut and paste this into VS... caveat...
Byte checksum(Byte[] InStr)
{
Uint sum = 0;
for (Int ct = 0; ct < InStr.Length; ct++)
{
sum += InStr[ct];
if (sum > 0x7F)
{
sum = sum & 0x7F;
sum++;
}
}
sum = ~sum;
sum &= 0x7F;
if (sum == 0)
sum = 0x7F;
return ((Byte)sum);
}
}
"Ciaran" <ci****@insero-technologies.com> wrote in message
news:f4*************************@posting.google.co m... Hi there,
I'm not very good at c and I was wondering if anyone could give me a hand converting the following code snippet to c# ...
BYTE checksum(BYTE *InStr, BYTE len) {
BYTE i, sum = 0;
for (i = 0; i < len; ++i) {
sum += InStr[i];
if (sum & 0x80) {
sum &= 0x7F;
++sum;
}
}
sum = ~sum; sum &= 0x7F;
if (sum == 0) sum = 0x7F;
return (sum);
}
Thanks a million !!!
I did not cut and paste this into VS... caveat...
Byte checksum(Byte[] InStr)
{
Uint sum = 0;
for (Int ct = 0; ct < InStr.Length; ct++)
{
sum += InStr[ct];
if (sum > 0x7F)
{
sum = sum & 0x7F;
sum++;
}
}
sum = ~sum;
sum &= 0x7F;
if (sum == 0)
sum = 0x7F;
return ((Byte)sum);
}
}
"Ciaran" <ci****@insero-technologies.com> wrote in message
news:f4*************************@posting.google.co m... Hi there,
I'm not very good at c and I was wondering if anyone could give me a hand converting the following code snippet to c# ...
BYTE checksum(BYTE *InStr, BYTE len) {
BYTE i, sum = 0;
for (i = 0; i < len; ++i) {
sum += InStr[i];
if (sum & 0x80) {
sum &= 0x7F;
++sum;
}
}
sum = ~sum; sum &= 0x7F;
if (sum == 0) sum = 0x7F;
return (sum);
}
Thanks a million !!! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Leader |
last post by:
HI,
i got a problem while using StrConv function in sql server.
My requirement is:-
suppose in a name field i have "jhon smith" Now i want to run a sql
which will give me the result like "Jhon...
|
by: DickChristoph |
last post by:
Hi
I am interested in converting a Access 97 application to VB.Net (well okay
rewriting). This would be a VB.Net client with a SQL Server backend, as
opposed to my other alternative which would...
|
by: prabha |
last post by:
Hello Everybody,
I have to conert the word doc to multiple html files,according to the templates in the word doc.
I had converted the word to xml.Also through Exsl ,had finished the multiple...
|
by: Robert |
last post by:
I have a series of web applications (configured as separate applications) on
a server.
There is a main application at the root and then several virtual directories
that are independant...
|
by: Mary |
last post by:
Hi,
Does anyone know of any software out there that would convert an application
written in VBScript to either VB.NET or C#/C++ quite quickly for me, or will
I have to re-write the application...
|
by: Map Reader |
last post by:
Greetings,
I am converting an old VB6 application to use .NET. One of the old controls
loads icons from the disk and displays them. However, the transparent color
turns to blue somewhere in the...
|
by: Tor Aadnevik |
last post by:
Hi,
I have a problem converting values from Single to double.
eg. When the Single value 12.19 is converted to double, the result is
12.1899995803833.
Anyone know how to avoid this?
Regards...
|
by: manmit.walia |
last post by:
Hello All,
I have tried multiple online tools to convert an VB6 (bas) file to
VB.NET file and no luck. I was hoping that someone could help me covert
this. I am new to the .NET world and still...
|
by: minterman |
last post by:
1. the program needs to convert btu to jules
2. Convert calories to joules
3. Convert joules to joules
4 exit the program.
if the user type anything other than 1-4 the program should print a...
|
by: ThunderMusic |
last post by:
Hi,
The subject says it all... I want to use a byte and use it as byte* so I
can increment the pointer to iterate through it.
What is the fastest way of doing so in C#?
Thanks
ThunderMusic
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |