C语言问题 从字母创建数字

请问这个怎么解决?下面是他的要求。编写一个 C 程序,file_hash.c,它被赋予一个文件名作为命令行参数。它应该打印从文件字节生成的单个数字

img

img

img

#include <stdio.h>
#include <stdint.h>

uint32_t hash(uint32_t old_hash_value, uint8_t byte, size_t index);

int main(int argc, char *argv[]) {

    // TODO: add your code here

    return 0;
}

// DO NOT CHANGE THIS FUNCTION

uint32_t hash(uint32_t old_hash_value, uint8_t byte, size_t index) {
    return old_hash_value + (byte << (index % 17));
}

#include <stdio.h>
#include <stdint.h>
uint32_t hash(uint32_t old_hash_value, uint8_t byte, size_t index);
int main(int argc, char *argv[]) {
    FILE *fp = NULL;
    int i;
     uint32_t hx = 0;
     unit32_t offset = 0;
    if(argc < 2)
          return 0;
    fp = fopen(argv[1],"r");
    if(fp != NULL)
    {
          char buf[1000];
          while(fgets(buf,1000,fp) != NULL)
          {
              i=0;
              while(buf[i] != 0)
              {
                    hx =  hash(hx,buf[i],offset);
                    i++;
                    offset++;
              }
          }
          fclose(fp);
          printf("%d",hx);
    }
    return 0;
}
// DO NOT CHANGE THIS FUNCTION
uint32_t hash(uint32_t old_hash_value, uint8_t byte, size_t index) {
    return old_hash_value + (byte << (index % 17));
}
 

不确定换行符参不参与哈希计算啊