c - 将 char 数组传递给 (void const *p)

标签 c arrays parameters char

我有一个源代码,其中有一个计算周校验和的函数。我需要传递一个字符数组,比如说“ Hello World ”。我怎样才能做到这一点??我尝试了一些方法,例如:

char textArr[] = 'hello world'

但我收到“ undefined reference ”错误。

unsigned int rs_calc_weak_sum(void const *p, int len) {
  unsigned char const    *buf = (unsigned char const *) p;
}

请帮我解决这个问题。

最佳答案

确保您的函数 rs_calc_weak_sum 在 main 之前原型(prototype)化/定义。

关于c - 将 char 数组传递给 (void const *p),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18086826/

相关文章:

c - 什么是 C 中的结构的清晰、简单的解释

c++ - 在 pragma 并行指令中将数组声明为共享变量并稳定代码

PHP Order数组基于元素依赖

javascript - 如何根据特定的 JSON 对象值对数组进行计数?

arrays - 将Struct数组元素作为参数传递给Go语言中的函数

c - 在 C 中包含守卫约定

c - 试图让这个显示功能起作用

javascript - array.push 不是函数 - 使用 reduce 时

javascript - ExtJs4 - 存储 baseParams 配置属性?

vue.js - 如何在 vue.js 中使用 router.push 传递参数?