UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » C
  • » Struct Example

#1 2007-07-09 02:38 PM

aaronc
Member
Registered: 2007-04-25
Posts: 8

Re: Struct Example

Hi,
In the example below, I am not sure what are the variables pt1, *ppt, pt2={1.8,3.9}; as from what I know, the correct notation should use typedef to declare those variables or are they part of struct?

struct point {
float x;
float y;
} pt1, *ppt, pt2={1.8,3.9};

Many Thanks
Aaron

Offline

#2 2007-07-09 03:28 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: Struct Example

It's a very very ugly way of doing:

struct point {
    float x;
    float y;
};

struct point pt1;
struct point *ppt;
struct point pt2 = {1.8, 3.9};

Typedef is something totally different, and would be only used to obfuscate the code even more.

Offline

  • Index
  • » C
  • » Struct Example

Board footer

Powered by FluxBB