473,395 Members | 1,869 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

initialization from incompatible pointer type

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
Nov 14 '05 #1
3 17741
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.
Nov 14 '05 #2
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?


First, read Section 6 of the comp.lang.c Frequently
Asked Questions list

http://www.eskimo.com/~scs/C-faq/top.html

to make sure you understand the differences between
pointers and arrays. Second, study the rest of the
program to try to divine the author's incorrectly-
expressed intent. Third, try to write a correct
expression of that intent; this may well require
changes outside the two lines you've shown.

Do *not* try to "solve" the problem by adding
a cast operator. That's like "fixing" your car's
oil pressure warning light by putting tape over it.

--
Er*********@sun.com

Nov 14 '05 #3
Thank you both for the suggestions. I am glad that I was told both
where to look to find out more about pointers and arrays as well as a
code solution.
Nov 14 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Me | last post by:
I am trying to compile some code Ive gotten from another and I know I need a 16 bit unicode string, for he passes the pointer to functions that take a (uint16 *), however there are initializations...
15
by: Chris Readle | last post by:
Hi all, Somewhat new to C and I'm getting the following error from my latest code. Here's the warning I'm getting: chris_readle_project3_assignment3.c: In function `main':...
12
by: natkw1 | last post by:
Hi, I'm attempting to understand the use of pointers(at least grasp how pointers work). I've read the FAQ on http://www.eskimo.com/~scs/C-faq/s6.html on pointers and arrays but I'm still a bit...
1
by: wanglei0214 | last post by:
I compiles a program in SLOS, but there is a warning i donot know how to remove? here is the framework of the code: typedef struct device_tree { ...... union {
13
by: william | last post by:
code segment: long int * size; char entry; ............. size=&entry; ************************************* Gcc reported 'assignment of incompatible pointer type'.
2
by: Antti Karanta | last post by:
Hi! Is it possible to inline initialize a struct whose one member is a string array of arbitrary length (terminated w/ a NULL ptr)? What I mean is something like this: typedef struct {...
17
by: copx | last post by:
I don't know what to think of the following.. (from the dietlibc FAQ) Q: I see lots of uninitialized variables, like "static int foo;". What gives? A: "static" global variables are initialized...
17
by: Andrea Taverna (Tavs) | last post by:
Subject: Initialization of a const matrix implemented as pointer-to-pointer Hello everyone. I've got the following matrix definition in a source file static const char **a; I need it to...
3
by: ricardopf | last post by:
Hello all, I'm facing some problems to compile a new module for Linux Ubuntu 8.04, kernel version 2.6. Above are two pieces of code related to the problem. linux/netfilter.h //begin...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.