Brian Stubblefield wrote:
Dear clc members,
I am rather new to the C programming language.
I have a rather large program that I am currently debugging.
Currently, the following snippet of code in the c program:
char skillkey[96][1];
char (*fillkey_ptr)[96]= skillkey;
results in a "warning: initialization from incompatible pointer type"
message during the compile.
What can I do to solve this issue?
Any help is greatly appreciated.
Thank you in advance,
Brian
On most linux systems, you have something called a 'cdecl' utility.
That could be a real boon to know what the declarations really mean, at
least to begin with.
$ cdecl
cdecl> explain char skillkey[96][1]
declare skillkey as array 96 of array 1 of char
cdecl> explain char (*fillkey_ptr)[96]
declare fillkey_ptr as pointer to array 96 of char
So essentially you are trying to assign two totally unrelated quantities.
#include <stdlib.h>
int main() {
char skillkey[96];
char (*fillkey_ptr)[96];
fillkey_ptr = &skillkey;
return EXIT_SUCCESS;
}
This code compiles perfectly fine.
But you need to ask yourself the objective of the declaration and its
usage.
HTH
--
Karthik.
Humans please 'removeme_' for my real email.