473,804 Members | 3,229 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

K&R p 130

mdh
Hi All,
Just when I thought things were going to get easy!

Structs.

I **thought** I had copied the examples pretty closely, but am getting
a number of errors.
The code:
>>>>>>
#include <stdio.h>
int main (int argc, const char * argv[]) {

struct point {
int x;
int y;
};
struct point makepoint( int, int); /* error. previous decl of
'makepoint' was here*/

struct point p1 = makepoint(8,9);

printf("%d, %d\n", p1.x, p1.y);
}


struct point makepoint(int x, int y) {
struct point temp;
temp.x = x;
temp.y = y;
return temp;
}

The error I got in the past has meant that something has been defined
twice, but as far as I can tell, ( probably incorrectly) I have
declared a struct called point, then declared a function which accepts
two integer arguments and returns a 'point' structure. Clearly I am
missing something.

In addition, I am getting a number of errors in makepoint function
defintion, which may become obvious once my initial query is cleared.
If not, I will ask then.

Lastly, K&R say , on p 130, of the makepoint function, "notice that
there is no conflict between the argument name and the member with the
same name". I assume that this refers to the lines

temp.x = x;
temp.y = y;

Thanks as usual.

Aug 17 '08
34 1939
Ben Bacarisse wrote:
Ron Ford <ro*@example.in validwrites:
>I don't know if you know it, but your usenet existence is somewhat
ethereal. I can't read your posts although I have the very good
news.individua l.net.

Noted, but I am not sure what I can do. Every one of my posts (that
I've had reason to look for) has shown up in Google for example
(including all of my posts in this thread) but it is possible that my
server is blocked by some parts of Usenet...

Where is it topical to discuss/investigate this?
As another NIN user, I don't think I've missed one of your posts.

--
Ian Collins.
Aug 20 '08 #31
On Aug 20, 6:20 am, Ben Bacarisse <ben.use...@bsb .me.ukwrote:
Ron Ford <r...@example.i nvalidwrites:
I don't know if you know it, but your usenet existence is somewhat
ethereal. I can't read your posts although I have the very good
news.individual .net.

Noted, but I am not sure what I can do. Every one of my posts (that
I've had reason to look for) has shown up in Google for example
(including all of my posts in this thread) but it is possible that my
server is blocked by some parts of Usenet...

Where is it topical to discuss/investigate this?
Using google groups, I see your posts frequently. I think that Ron
Ford person is a troll.
Google some of his previous articles in comp.lang.c
Aug 20 '08 #32
Ben Bacarisse wrote:
Ron Ford <ro*@example.in validwrites:
I don't know if you know it, but your usenet existence is somewhat
ethereal. I can't read your posts although I have the very good
news.individual .net.

Noted, but I am not sure what I can do.
I'm also using NIN, and I'm seeing lots of posts from you. I think any
problems Ron is having is due to his setup.


Brian
Aug 20 '08 #33
On Thu, 21 Aug 2008 11:24:09 -0600, Ron Ford wrote:
Ben, I still don't see your posts, and this is the only scoring I have
for clc:
[comp.lang.c]
!delete From "Ari"
I don't actually know your newsreader's filter, but unless it's case
sensitive or searches for words instead of characters, you're _telling_ it
to delete Ben Bacarisse's messages.
Aug 21 '08 #34
On 19 Aug 2008 07:59:18 GMT, Chris Torek <no****@torek.n etwrote:
<snip: struct tag { body } within function>
In article <73************ *************** *******@i24g200 0prf.googlegrou ps.com>
mdh <md**@comcast.n etwrote:
OK..., this is unique only to structs, unions and enums. And if so,

(Presumably the statement here -- ending with a period -- was
meant as a question.) Yes, it is in fact unique to those three.
is this due to the complicated nature of those objects,

Not exactly. Instead, it is due to the fact that those three
things are the three ways that C allows users to define new
data-types.

The "struct" keyword does one of three things:

- refer to an existing struct type;
- declare a new, incomplete struct type; or
- define a new struct type (or -- really the same thing --
complete an incomplete one).
Yes. #1 existing _and visible_, to be absolutely precise.
The union and enum keywords do the same; the only real difference
is when defining types (because a union defines a bunch of
"overlappin g" members, only one of which you can use at a time,
and an enum defines a bunch of integer constants).
union yes, but standardly you can't forward-declare enum (6.7.2.3p2).
I suspect this is because all struct pointers must 'smell' the same,
and so must all union pointers, but enums smell like integer types,
possibly different ones, so pointers to them are allowed to differ. On
implementations where all enums 'are' int, which are many, or all
(data) pointers look the same, which is more, it can be an extension.

<snip rest; long, and good, as usual>
- formerly david.thompson1 || achar(64) || worldnet.att.ne t
Sep 1 '08 #35

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

Similar topics

9
8581
by: Collin VanDyck | last post by:
I have a basic understanding of this, so forgive me if I am overly simplistic in my explanation of my problem.. I am trying to get a Java/Xalan transform to pass through a numeric character reference (i.e.  ) and it seems to be converting the character to its UNICODE representation. Take this source XML document: <?xml version="1.0" encoding="UTF-8"?>
1
11445
by: DrTebi | last post by:
Hello, I have the following problem: I used to "encode" my email address within links, in order to avoid (most) email spiders. So I had a link like this: <a href="mailto:DrTebi@yahoo.com">DrTebi</a> This would work like a regular mailto link in any browser, but wouldn't be visible to spiders if they don't have a function to decode it.
0
2425
by: Thomas Scheffler | last post by:
Hi, I runned in trouble using XALAN for XSL-Transformation. The following snipplet show what I mean: <a href="http://blah.com/?test=test&amp;test2=test2">Test1&amp;</a> <a href="http://blah.com/?test=test&amp;amp;test2=test2">Test2&amp;amp;</a> This results in the following HTML Code:
4
3036
by: Luklrc | last post by:
Hi, I'm having to create a querysting with javascript. My problem is that javscript turns the "&" characher into "&amp;" when it gets used as a querystring in the url EG: /mypage.asp?value1=1&amp;value2=4&amp; ... which of course means nothing to asp.
4
3230
by: johkar | last post by:
When the output method is set to xml, even though I have CDATA around my JavaScript, the operaters of && and < are converted to XML character entities which causes errors in my JavaScript. I know that I could externalize my JavaScript, but that will not be practical throughout this application. Is there any way to get around this issue? Xalan processor. Stripped down stylesheet below along with XHTML output. <?xml version='1.0'?>...
8
2819
by: Nathan Sokalski | last post by:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add() method as follows: Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);" TextBox2.Attributes.Add("onKeyPress", jscode) You will notice that jscode contains the JavaScript Logical And operator (&&). However, ASP.NET renders this as &amp;&amp; in the code that is
11
6447
by: Jeremy | last post by:
How can one stop a browser from converting &amp; to & ? We have a textarea in our system wehre a user can type in some html code and have it saved to the database. When the data is retireved and
14
5942
by: Arne | last post by:
A lot of Firefox users I know, says they have problems with validation where the ampersand sign has to be written as &amp; to be valid. I don't have Firefox my self and don't wont to install it only because of this, so I hope some of you gurus can enlighten me with this :) In what circumstances can the "&amp;" in the source code be involuntary changed to "&" by a browser when or other software, when editing and uploading the file to the web...
12
10124
by: InvalidLastName | last post by:
We have been used XslTransform. .NET 1.1, for transform XML document, Dataset with xsl to HTML. Some of these html contents contain javascript and links. For example: // javascript if (a &gt; b) ..... // xsl contents abc.aspx?p1=v1&amp;p2=<xsl:value-of select="$v2" />
7
4633
by: John Nagle | last post by:
I've been parsing existing HTML with BeautifulSoup, and occasionally hit content which has something like "Design & Advertising", that is, an "&" instead of an "&amp;". Is there some way I can get BeautifulSoup to clean those up? There are various parsing options related to "&" handling, but none of them seem to do quite the right thing. If I write the BeautifulSoup parse tree back out with "prettify", the loose "&" is still in there. So...
0
9708
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10588
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10340
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9161
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7623
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5527
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4302
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 we have to send another system
2
3827
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2998
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.