473,466 Members | 1,346 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Structs with pointers

Hi there,

I got a little problem with a program I'm writing:

I use some structs, the definitions are as follows:

struct GitterPunkt{
float a[ANZ_SENSOREN];
float d[ANZ_SENSOREN];
float p[ANZ_SENSOREN];
float p4ges;
float p3ges;
float r;
float phi;
};

struct ErgMax{
struct Gitterpunkt *randlinks;
struct Gitterpunkt *randrechts;
struct Gitterpunkt *randunten;
struct Gitterpunkt *randoben;
struct Gitterpunkt *max3;
struct Gitterpunkt *max4;
};

struct GitterPunkt gitter[N][M]; /* N and M are definde like #define M
10 */

struct idl{
char id[ANZ_SENSOREN];
struct ErgMax *erg;
struct idl *next;
};
My Program is a bit long to post it here, but I think there are only few
lines important:

struct idl *aktid=0;
/* some code, aktid changes to !0 */
aktid->erg->randoben=&gitter[i][j]; /* it's in a loop with i and j for
counters */

I have got several assignments like the one above and I get the same
compilation error everytime:

auswerten.c:73: Warnung: Zuweisung von inkompatiblem Zeigertyp

Because I use a german system the warning is in german, too. In english
it's something like: "auswerten.c:73: Warning: Assigment with
incompatible Pointertype" (free translated)

I'm puzzled, I don't have any clue what is going wrong. Does anybody
here got an idea?

Normaly randoben should get a pointer to a Gitterpunkt (fix in i and j),
but the compiler says, that the pointer are incompatible...

Thx in advance
Nov 14 '05 #1
5 1271
Hanno Boettcher <ha*************@tu-harburg.de> wrote:
Hi there,

I got a little problem with a program I'm writing:

I use some structs, the definitions are as follows:

struct GitterPunkt{ [...]};

struct ErgMax{
struct Gitterpunkt *randlinks;
struct Gitterpunkt *randrechts;
struct Gitterpunkt *randunten;
struct Gitterpunkt *randoben;
struct Gitterpunkt *max3;
struct Gitterpunkt *max4;

^--- How a simple typo can mess things up.

struct Gitterpunkt != struct GitterPunkt

Regards
--
Irrwahn Grausewitz (ir*******@freenet.de)
welcome to clc: http://www.ungerhu.com/jxh/clc.welcome.txt
clc faq-list : http://www.faqs.org/faqs/C-faq/faq/
clc OT guide : http://benpfaff.org/writings/clc/off-topic.html
Nov 14 '05 #2
In 'comp.lang.c', Hanno Boettcher <ha*************@tu-harburg.de> wrote:
struct GitterPunkt{ <...> struct Gitterpunkt *randunten; <...> struct GitterPunkt gitter[N][M]; /* N and M are definde like #define M
10 */

<...>

Check you code one more time: 'GitterPunkt' is not 'Gitterpunkt'. C is case
sensitive.

--
-ed- get my email here: http://marreduspam.com/ad672570
The C-language FAQ: http://www.eskimo.com/~scs/C-faq/top.html
C-reference: http://www.dinkumware.com/manuals/reader.aspx?lib=c99
FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/
Nov 14 '05 #3
Emmanuel Delahaye wrote:
In 'comp.lang.c', Hanno Boettcher <ha*************@tu-harburg.de> wrote:

struct GitterPunkt{


<...>
struct Gitterpunkt *randunten;


<...>
struct GitterPunkt gitter[N][M]; /* N and M are definde like #define M
10 */


<...>

Check you code one more time: 'GitterPunkt' is not 'Gitterpunkt'. C is case
sensitive.


AHHH, thx!
<-- I'm with stupid
Nov 14 '05 #4

"Hanno Boettcher" <ha*************@tu-harburg.de> wrote

AHHH, thx!
<-- I'm with stupid

This is an argument for typedefing your structs.

typedef struct
{
int x;
/* blah */
}GitterPunkt.

Now if you type

Gitterpunkt *ptr;

the compiler should tell you that the declaration is invalid because it
doesn't understand the identifier, rather than down the line when it tries
to match up the struct.

However I'm surprised that a German should make an error in use of capitals.
Nov 14 '05 #5
Malcolm wrote:
"Hanno Boettcher" <ha*************@tu-harburg.de> wrote
AHHH, thx!
<-- I'm with stupid

This is an argument for typedefing your structs.

typedef struct
{
int x;
/* blah */
}GitterPunkt.

Now if you type

Gitterpunkt *ptr;

the compiler should tell you that the declaration is invalid because it
doesn't understand the identifier, rather than down the line when it tries
to match up the struct.

However I'm surprised that a German should make an error in use of capitals.

Even Germans aren't perfect :-)

Nov 14 '05 #6

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

Similar topics

1
by: Dave A | last post by:
The following C code specifies the interface into a DLL. I need to access it from C#. How do I do declare it? I have done simple ones before but this particular API requires a pointer to a struct...
3
by: Christian F | last post by:
Hi, I'm a C-newbie and I would like to know if I am doing something wrong in the code below. It is working, but I'm afraid it might not be correct because I don't really understand everything of...
5
by: Paminu | last post by:
Why make an array of pointers to structs, when it is possible to just make an array of structs? I have this struct: struct test { int a; int b;
5
by: Bilgehan.Balban | last post by:
Hi, I am currently brushing up my c++ knowledge and I would like to ask you about the differences between classes and C structs, in the function/method perspective. 1) Is it correct to say...
15
by: Paminu | last post by:
Still having a few problems with malloc and pointers. I have made a struct. Now I would like to make a pointer an array with 4 pointers to this struct. #include <stdlib.h> #include <stdio.h>...
12
by: barcaroller | last post by:
Is it legal to compare the contents of two multi-field variables (of the same struct) using "==" and "!="? struct { int a; int b; } x,y; ...
17
by: Johan Tibell | last post by:
Could someone outline the pros and cons of typedefing pointers to structs like this? typedef struct exp_ { int val; struct exp_ *child; } *exp; (This is straight from memory so it might not...
11
by: Cliff Martin | last post by:
Hi, I am reading a fairly large file a line at a time, doing some processing, and filtering out bits of the line. I am storing the interesting information in a struct and then printing it out....
5
by: dev_15 | last post by:
Hi, I'm going through some code and thought that this allocates an array of structs but its supposed according to comments to allocate an array of pointer to structs. What does it actually do ...
2
by: hal | last post by:
Hi, I'm trying to make an array of pointers to 'TwoCounts' structs, where the size of the array is arraySize. Right now I'm just mallocing enough space for all the pointers to the structs, and...
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
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.