Question
Working with a program in c that reads in a file and then I have to do both 8 bit and 16 bit checksum for
Working with a program in c that reads in a file and then I have to do both 8 bit and 16 bit checksum for a program.I only have 8 bit checksum done so far.
This is what I understand
I read the file and store the information in an array of characters and at end it takes the newline feed. so for example to calculate 8 bit check sum this is what happens essentially
File has 3 letters total ( 3 a's and a newline feed)
so array holds 4 chars aaa+(newline) (97+97+97+10)
To my understanding I add all the bytes in the array then do % 256 and that is my checksum.
97 * 3 = //3 a's (small a ) pulled from ascii table from what I understand
291 + 10 = 301 // + newline
301 % 256 = cc in hex //
however I am getting confused on how to calculate the 16 bit checksum because I can't add 2 characters at a time if its a single character array? any help would be greatly appreciated
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started