comp.lang.c - 26 new messages in 9 topics - digest
comp.lang.c
http://groups.google.com/group/comp.lang.c?hl=en
Today's topics:
* C from Fortran Calls - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c/t/ec59d7fd61d468f8?hl=en
* Has thought been given given to a cleaned up C? Possibly called C+. - 10
messages, 8 authors
http://groups.google.com/group/comp.lang.c/t/5954dc70a43f9f8e?hl=en
* how to get out of double for loops? - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c/t/535cb24e8f02aec3?hl=en
* One of my first C functions - Please comment - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.c/t/25eb4de52a6a4e6d?hl=en
* Stylistic questions on UNIX C coding. - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/51d2b24a60d73f18?hl=en
* Got stuck with quicksort code from the "Unleashed C". - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/0fb91f93b991c210?hl=en
* Concerns Heathfield's and Seebach's behavior: please read - 1 messages, 1
author
http://groups.google.com/group/comp.lang.c/t/cc475a35adc056e8?hl=en
* ANNOUNCE: WinGDB - debugging with GDB under Visual Studio - 5 messages, 5
authors
http://groups.google.com/group/comp.lang.c/t/caa9b97bbee41cd4?hl=en
* A Minor Problem With atoi() And Negative Numbers - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/5218f6623a71b4c1?hl=en
==============================================================================
TOPIC: C from Fortran Calls
http://groups.google.com/group/comp.lang.c/t/ec59d7fd61d468f8?hl=en
==============================================================================
== 1 of 2 ==
Date: Mon, Mar 8 2010 11:29 am
From: Ian Bush
On 8 Mar, 16:32, deadpickle <deadpic...@gmail.com> wrote:
>
> Thanks for all the help. I'm trying to pass an array to my C code from
> fortran. In C I have the variable declared:
> double *shparray[2][*shpnum]
> but when I go to print its contents I get:
> for (a=0;a < *shpnum; a++)
> {
> //~ add point to geometry
> printf("%lf,%lf\n",*shparray[1][a], *shparray[0][a]);
> OGR_G_AddPoint(line, *shparray[1][a], *shparray[0][a], 0);
> printf("Adding Point:\"%lf %lf\"\n",shparray[0][a],shparray[1][a]);
> }
>
> I get a segfault. Am I passing the array correctly?
>
> void add_shp(int *shpnum,int *eventnum,double *shparray[2]
> [*shpnum],double *shperror,char *passer,int *tracknum)
No idea. You've only posted half the problem. What does the Fortran
side look like - including
the declarations of all variables and the interface block; a complete
program showing the
problem is what would allow us to work out what is wrong quickest.
Better follow Ben's advice and post this with the info I've asked for
in clf. You'll get an answer
there.
(Actually a slight lie, shparray looks very suspicious - you are aware
of the difference between row
and column major? But I'm not pshycic, I can't guess quite how it is
wrong without both sides of the
problem)
Ian
== 2 of 2 ==
Date: Mon, Mar 8 2010 11:42 am
From: Malcolm McLean
On Mar 8, 4:32 pm, deadpickle <deadpic...@gmail.com> wrote:
> Thanks for all the help. I'm trying to pass an array to my C code from
> fortran. In C I have the variable declared:
> double *shparray[2][*shpnum]
> but when I go to print its contents I get:
>
This looks like garbage. It probably means something in the particular
dialect of C that your compiler uses, but not what want it to mean.
When passing Fortran to C, it's best to simply collapse the variable
into a raw pointer. You have no type safety anyway, and C arrays are
in column-major as opposed to row-major order, and zero-based as
opposed to 1-based, so effectively an entire reinterpretation is
needed.
==============================================================================
TOPIC: Has thought been given given to a cleaned up C? Possibly called C+.
http://groups.google.com/group/comp.lang.c/t/5954dc70a43f9f8e?hl=en
==============================================================================
== 1 of 10 ==
Date: Mon, Mar 8 2010 11:29 am
From: Malcolm McLean
On 8 Mar, 08:59, Thomas Richter <t...@math.tu-berlin.de> wrote:
>
> You still don't get it, don't you? I'm not a "C++ advocate". I'm a "use
> the right tool for the job" advocate. That might be C, C++, java,
> pyhton, bash, or whatever else is out in the field.
>
That sounds so sensible that no-one would ever disagree with it.
The problem comes when the costs to using the tools are significant.
Imagine a carpenter who has to walk from village to village picking up
odd jobs. He'll take a hammer and a saw. A lathe and a drill would
also be handy, but take too much and he's got to hire an assistant to
carry the toolbag, which means that he'll have to bump up his charges
considerably. Using a nail where ideally you'd put a screw might be
the best solution.
Similarly the costs of having some code in C, some in C++, some in
Java, some in Python are very considerable.
--
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
== 2 of 10 ==
Date: Mon, Mar 8 2010 11:30 am
From: Lorenzo Villari
On Mon, 8 Mar 2010 02:59:32 -0600 (CST)
Thomas Richter <thor@math.tu-berlin.de> wrote:
>
> You still don't get it, don't you? I'm not a "C++ advocate". I'm a
> "use the right tool for the job" advocate. That might be C, C++,
> java, pyhton, bash, or whatever else is out in the field. For complex
> algorithms on a desktop system, I wouldn't use C. Neither would I use
> C++ for a GUI-intensive problem, java is much better suited for that,
> nor would I write scripts in java, that's what I use python for.
>
What does it means "GUI-intensive" and why should java be better at
solving these kinds of problems? Excluding subjective aesthetic
consideration on the resulting GUIs, I think some operations
"could" (but I'm unaware of recent changes so I could be wrong) be a bit
slower than an analogous C or C++ counterpart. Of course if maximum
speed is not required that's ok. A slow menu is not that cool btw...
--
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
== 3 of 10 ==
Date: Mon, Mar 8 2010 11:31 am
From: cri@tiac.net (Richard Harter)
On Mon, 8 Mar 2010 02:59:32 -0600 (CST), Thomas Richter
<thor@math.tu-berlin.de> wrote:
>jacob navia schrieb:
>
>> My opinion is that C should be developed further, exactly BECAUSE is
>> a simple language. Adding a container library to C doesn't make the
>> language any bigger or more complicated but makes programs COMPATIBLE
>> because it is possible to interchange data with standard API/containers.
>>
>> There is no way in C to return a list of the files in a directory. Nor
>> there is a standard way to return a flexible array, or similar
>> containers.
>
>Not in C, but in POSIX, which is implemented by most C compilers. This
>is basically because the execution environment of some C compilers do
>not have the notion of a directory. Actually, there are no means to do
>the same in C++, and for the same reason.
The answer to this is that the standard could have environment
dependent sections. Thus the standard could say that IF the
environment supports a directory based file system then the
implementation provides the corresponding POSIX library.
Having a container library is a different kind of issue because
it isn't environment dependent. The standard could specify a
container library. The sticking point is what should it look
like.
Richard Harter, cri@tiac.net
http://home.tiac.net/~cri, http://www.varinoma.com
It's not much to ask of the universe that it be fair;
it's not much to ask but it just doesn't happen.
--
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
== 4 of 10 ==
Date: Mon, Mar 8 2010 11:31 am
From: ImpalerCore
On Mar 7, 5:13 pm, Ian Collins <ian-n...@hotmail.com> wrote:
> jacob navia wrote:
>
> > C is still being used, and many important projects are based on it. My
> > thesis is that a simple language is necessary and useful. Adding
> > a general and extensible container interface for C doesn't change at all
> > the language but gives C programmer the advantages of not having to
> > program the same data structures over and over.
>
> > The proliferation of libraries that do the same thing WITHOUT a standard
> > in C means that each big project in C has several versions of the same
> > data structure because library XYZ uses lists with the "Next" field
> > in the fiorst position and library"XXX" uses a list with Next in the
> > second position. Besides all APIs are different, etc.
>
> One interesting question is why, after over 30 years of use, there
> hasn't appeared a widely accepted a general and extensible container
> interface for C?
>
> The C++ STL appeared fairly early on in that language's evolution and
> was rapidly and widely accepted by C++ developers. The widespread use
> resulted in it being incorporated into the standard library in first
> language standard.
>
> Why hasn't the same thing happened with C?
That is a very good question. I think that you may have hinted at the
problem already, "C++ STL appeared fairly early on".
I imagine that the Stepanov and other people pursuing generic
containers didn't think C could provide the right support. The fact
that C++ standardization was fluid while he was working on his ideas
certainly made for easier acceptance by that language. C++ at that
time had much less inertia compared to C, and better language support
for his ideas. The longer a feature (the two big ones are a standard
container library, and concurrency) is not available in the
development of a language's toolset, the more likely that the
implementation of that feature will be fragmented across the
architectures and the people who need it. I believe the fact that the
STL came together in C++'s infancy led to more general acceptance as a
whole. Delay the STL enough, maybe a couple of years, and I believe
that C++ would have had the same problem, maybe.
I may be completely off, but those are my current thoughts on the
question.
Best regards,
John D.
> --
> Ian Collins
> --
> comp.lang.c.moderated - moderation address: c...@plethora.net -- you must
> have an appropriate newsgroups line in your header for your mail to be seen,
> or the newsgroup name in square brackets in the subject line. Sorry.
--
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
== 5 of 10 ==
Date: Mon, Mar 8 2010 11:32 am
From: ImpalerCore
On Mar 7, 7:04 pm, jacob navia <ja...@spamsink.net> wrote:
> Ian Collins a écrit :
>
> > jacob navia wrote:
>
> > One interesting question is why, after over 30 years of use, there
> > hasn't appeared a widely accepted a general and extensible container
> > interface for C?
>
> > The C++ STL appeared fairly early on in that language's evolution and
> > was rapidly and widely accepted by C++ developers. The widespread use
> > resulted in it being incorporated into the standard library in first
> > language standard.
>
> > Why hasn't the same thing happened with C?
>
> Because the C standards committee has always decided NOT to add such
> an improvement to the language. The C++ standard committee decided that
> such an improvement WAS NECESSARY, and they develop one.
>
> I have written most of the STL clone (AVL trees, RB trees, bitstrings,
> flexible arrays, lists (double/single linked) and the whole library
> is extremely fast and compact. It is just less than 100K when you use
> all of it. If you use just the lists module it is less than 5K.
>
> But apparently all this work is a waste of time. The committee decided
> a feature freeze already, and I will not be ready to present this to
> the next meeting in April.
And C has been waiting for a standard generic container library for
what, like 30 years? I don't think there's any hurry on this, and I
don't know if the committee is even looking for a container library.
I believe that the C++ committee reached out to Stepanov, or it's
likely that his work wouldn't have come to fruition in C++ the way it
did. I would think that a container library having 'de-facto'
standardization similar to boost would be a prerequisite to even think
about C standardization. Why should they invest a lot of time and
energy debating the rules and semantics when the result may not be
accepted by the compiler or C community at large? Having a de-facto
library that has garnered support from the C community would give your
argument a bit more weight.
I don't know if it's even possible to get a de-facto container
standard these days. Many people have their own pet library that they
use and it may be difficult if not impossible to motivate them away
from it. I believe that your pursuit of a generic standardized
container library in C would be an endurance race, not a sprint.
I don't believe the work is ever a waste of time. Even if the C
standard committee rejects your proposal doesn't invalidate the
attempt. If you make standard committee acceptance or rejection your
definition of whether the effort is worth it, then I believe you are
doing it for the wrong reasons. If you are doing it because you love
doing it, then the work *is* worth it no matter the outcome. In the
end, you have to realize that the only person who you have control of
is yourself.
Best regards,
John D.
> --
> comp.lang.c.moderated - moderation address: c...@plethora.net -- you must
> have an appropriate newsgroups line in your header for your mail to be seen,
> or the newsgroup name in square brackets in the subject line. Sorry.
--
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
== 6 of 10 ==
Date: Mon, Mar 8 2010 12:02 pm
From: Jasen Betts
On 2010-03-07, Ian Collins <ian-news@hotmail.com> wrote:
> jacob navia wrote:
>>
>> C is still being used, and many important projects are based on it. My
>> thesis is that a simple language is necessary and useful. Adding
>> a general and extensible container interface for C doesn't change at all
>> the language but gives C programmer the advantages of not having to
>> program the same data structures over and over.
> >
>> The proliferation of libraries that do the same thing WITHOUT a standard
>> in C means that each big project in C has several versions of the same
>> data structure because library XYZ uses lists with the "Next" field
>> in the fiorst position and library"XXX" uses a list with Next in the
>> second position. Besides all APIs are different, etc.
>
> One interesting question is why, after over 30 years of use, there
> hasn't appeared a widely accepted a general and extensible container
> interface for C?
>
> The C++ STL appeared fairly early on in that language's evolution and
> was rapidly and widely accepted by C++ developers. The widespread use
> resulted in it being incorporated into the standard library in first
> language standard.
>
> Why hasn't the same thing happened with C?
too much work for too little gain.
C does not have templates, only macros, and using macros template
functiuons longer than 5 lines are hard to maintain, and longer than
50 are impossible.
--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
--
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
== 7 of 10 ==
Date: Mon, Mar 8 2010 1:46 pm
From: Seebs
On 2010-03-08, jacob navia <jacob@jacob.remcomp.fr> wrote:
> No. It is just that it loops:
I think you are not following his argument.
> jacob: We can improve C by adding A and B
> thomas: No, C can't be improved. It is a bad language because
> it lacks A and B. Use C++ instead.
He absolutely said nothing of the sort.
He did not say C was "a bad language". He did not say "C can't be improved".
He did say that he didn't think that adding A and B to C would improve it,
but rather, that it would make more sense to use languages which have
them.
You know what's an awesome feature in a programming language? An "eval"
operation, which interprets strings as code. Incredibly flexible and
powerful.
Do you think we should add eval() to C? I don't.
> thomas: C is low level and nothing should be improved. It is low level
> because it lacks A and B. Use C++ that has A and B.
I do not think this is a fair representation of his argument.
Here is a piece of advice I got from a friend once: If you want to argue
with someone, a good starting point is to understand their position well
enough that you can present their argument well enough that *they* agree
that you are presenting their argument fairly and well. If you can do that,
then it's reasonable to move on to arguing with them. If every time you
claim you are presenting their argument, they say "no, that's not what I
said at all", then you aren't ready to argue against them, because you don't
understand what they said.
I believe his argument is that he does not feel that adding A and B would
improve C. For instance, I don't think that adding operator overloading would
improve C. I think it would make C worse. One of the things I like about
C is the confidence that I know what it's doing. Operator overloading is
a great fit for an OO language, where I expect objects to have internal state
and define their own rules. It's a poor fit for a language where I
expect operations to map very closely onto machine instructions.
-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
--
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
== 8 of 10 ==
Date: Mon, Mar 8 2010 1:47 pm
From: Seebs
On 2010-03-08, ImpalerCore <jadill33@gmail.com> wrote:
> And C has been waiting for a standard generic container library for
> what, like 30 years? I don't think there's any hurry on this, and I
> don't know if the committee is even looking for a container library.
I'm not on the committee these days, but I really don't think a container
library is the right class of problem for the language spec to solve.
There are simply too many design tradeoffs that, *for C programs*, are too
significant for the language to nail them down.
The problem is, if we provide a "container library" in the spec, people
will be strongly inclined to use it even when it's a bad fit. I'm not sure
I want to do that -- look at the damage done by rand()!
I have seen a few possible container designs for C. None of them have
particularly appealed to me. Of the ones I've seen, the one that... uhm...
Guy whose name I've forgotten. The "embedded containers" approach, where
you have a list pointer anywhere in an object, and convert a pointer to the
list member of the object back into a pointer to the object. That's by far
the nicest -- and I'd never seen it until a couple-few months ago. Which
is to say, if we'd standardized any of the things I'd heard of by 2005 in
the language, we'd have missed a really good idea.
> I don't know if it's even possible to get a de-facto container
> standard these days. Many people have their own pet library that they
> use and it may be difficult if not impossible to motivate them away
> from it. I believe that your pursuit of a generic standardized
> container library in C would be an endurance race, not a sprint.
I would agree. And I think it's important to realize that there are going
to be mutually-exclusive requirements, so either you implement more than one,
or you write it off as being impossible.
> I don't believe the work is ever a waste of time. Even if the C
> standard committee rejects your proposal doesn't invalidate the
> attempt. If you make standard committee acceptance or rejection your
> definition of whether the effort is worth it, then I believe you are
> doing it for the wrong reasons. If you are doing it because you love
> doing it, then the work *is* worth it no matter the outcome. In the
> end, you have to realize that the only person who you have control of
> is yourself.
Totally agreed. I don't expect the language to pick up my string library
or my list library, but I use them and like having them around.
-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
--
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
== 9 of 10 ==
Date: Mon, Mar 8 2010 1:47 pm
From: Walter Banks
Ian Collins wrote:
> jacob navia wrote:
> > The proliferation of libraries that do the same thing WITHOUT a standard
> > in C means that each big project in C has several versions of the same
> > data structure because library XYZ uses lists with the "Next" field
> > in the fiorst position and library"XXX" uses a list with Next in the
> > second position. Besides all APIs are different, etc.
>
> One interesting question is why, after over 30 years of use, there
> hasn't appeared a widely accepted a general and extensible container
> interface for C?
Feature additions in C essentially takes two things.
1) A working example of new feature that is part of a current set of tools.
This is important to understand the implementation ramifications
and resolve the implementation conflicts that transforms a good
idea into good practice.
2) A champion that will formally explain and promote the new feature.
New ideas are debated on several levels. Does the new
feature address a real need, does the need have a broad application.
Are there alternative approaches. What is the impact on the existing
code base.
To answer the question some of the same people serve on C and C++
committees and one of the differences they saw between the languages
was it was more appropriate for an extensible container to be promoted
for C++ and not in C. I don't remember an extensible container
interface for C ever being discussed in WG-14.
Regards,
Walter..
--
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
== 10 of 10 ==
Date: Mon, Mar 8 2010 1:48 pm
From: jacob navia
Jasen Betts a écrit :
> On 2010-03-07, Ian Collins <ian-news@hotmail.com> wrote:
>> Why hasn't the same thing happened with C?
>
> too much work for too little gain.
>
> C does not have templates, only macros, and using macros template
> functiuons longer than 5 lines are hard to maintain, and longer than
> 50 are impossible.
>
A container library doesn't need macros. You can use void * and
it works.
I have developed a container library using plain C, and I have
already:
o lists (single/double linked)
o flexible arrays
o bitstrings
o AVL trees
o Red/Black trees
and it is not finished yet.
--
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
==============================================================================
TOPIC: how to get out of double for loops?
http://groups.google.com/group/comp.lang.c/t/535cb24e8f02aec3?hl=en
==============================================================================
== 1 of 2 ==
Date: Mon, Mar 8 2010 11:33 am
From: Eric Sosman
On 3/8/2010 11:22 AM, lawrence.jones@siemens.com wrote:
> Ben Bacarisse<ben.usenet@bsb.me.uk> wrote:
>>
>> Eric's did register on my humour meter but Lawrence is talking a load
>> of mallocs.
>
> Hey, let's not cast aspersions.
... nor make it an automatic response to dish out this
type of static.
--
Eric Sosman
esosman@ieee-dot-org.invalid
== 2 of 2 ==
Date: Mon, Mar 8 2010 12:46 pm
From: Flash Gordon
Eric Sosman wrote:
> On 3/8/2010 11:22 AM, lawrence.jones@siemens.com wrote:
>> Ben Bacarisse<ben.usenet@bsb.me.uk> wrote:
>>>
>>> Eric's did register on my humour meter but Lawrence is talking a load
>>> of mallocs.
>>
>> Hey, let's not cast aspersions.
>
> ... nor make it an automatic response to dish out this
> type of static.
if we could break out of this loop it would be good, but we can't while
the coding standards forbid it.
--
Flash Gordon
==============================================================================
TOPIC: One of my first C functions - Please comment
http://groups.google.com/group/comp.lang.c/t/25eb4de52a6a4e6d?hl=en
==============================================================================
== 1 of 3 ==
Date: Mon, Mar 8 2010 11:48 am
From: Richard
Nick <3-nospam@temporary-address.org.uk> writes:
> Malcolm McLean <malcolm.mclean5@btinternet.com> writes:
>
>> It's knock-up code. The trick in making in neat is to use the standard
>> library functions to do some of the messiness for you. Here's an
>> untested version.
>>
>> int longestpath(char *pathname, char sep)
>> {
>> char *ptr = pathname;
>> int answer = 0;
>> int dist;
>> char *sepptr;
>>
>> while(ptr)
>> {
>> sepptr = strchr(ptr, sep);
>> /* this is a nasty bit, exclude escapes */
>> while(sepptr > ptr && *(sepptr-1) == ESCSEQ))
>> septpr = strrchr(sepptr+1, sep);
>>
>> if(sepptr)
>> dist = sepptr - ptr -1;
>> else
>> dist = strlen(ptr);
>> if(dist > answer)
>> answer = dist;
>> ptr = sepptr;
>> if(ptr)
>> ptr = ptr + 1;
>> }
>> }
>>
>> answer will give length, including anyescape characters.
>>
>> A question for mediumbies: why do we say ptr = ptr +1 rather than ptr+
>> +?
>
> I haven't a clue. Any why not ptr += 1?
>
> Of course, you could do:
> [snip]
>> if(sepptr)
> {
>> dist = sepptr - ptr -1;
> sepptr += 1;
Horrible. I have almost never seen that in years of C programming. The
idiom in C is to use ++ for pointer advancement.
> }
>> else
>> dist = strlen(ptr);
>> if(dist > answer)
>> answer = dist;
>> ptr = sepptr;
>> }
>
> Yes, you could avoid adding a line by
> dist = sepptr++ - ptr -1;
> but that seems too confusing.
Really? Certainly not the ++ part. If you dont understan that then you
should not be programming in C.
What I find confusing there is the lack of brackets and need to work out
which way it works in regard to the "-" pair. Or rather I KNOW at a
later date it will confuse others. I never learnt precedence rules and
always bracket to make it explicit.
--
"Avoid hyperbole at all costs, its the most destructive argument on
the planet" - Mark McIntyre in comp.lang.c
== 2 of 3 ==
Date: Mon, Mar 8 2010 1:18 pm
From: pete
Malcolm McLean wrote:
> if(ptr)
> ptr = ptr + 1;
> }
> }
>
> answer will give length, including anyescape characters.
>
> A question for mediumbies: why do we say ptr = ptr +1 rather than ptr+
> +?
Because it's our first day programming
and we haven't learned the increment operator yet.
I prefer the prefix form, when the expression is not a subexpression:
++ptr;
--
pete
== 3 of 3 ==
Date: Mon, Mar 8 2010 1:37 pm
From: Eric Sosman
On 3/8/2010 2:14 PM, Nick wrote:
> Malcolm McLean<malcolm.mclean5@btinternet.com> writes:
>
>> It's knock-up code. The trick in making in neat is to use the standard
>> library functions to do some of the messiness for you. Here's an
>> untested version.
>>
>> int longestpath(char *pathname, char sep)
>> {
>> char *ptr = pathname;
>> int answer = 0;
>> int dist;
>> char *sepptr;
>>
>> while(ptr)
>> {
>> sepptr = strchr(ptr, sep);
>> /* this is a nasty bit, exclude escapes */
>> while(sepptr> ptr&& *(sepptr-1) == ESCSEQ))
>> septpr = strrchr(sepptr+1, sep);
Is it "Spot the UB Week" again already? Relational
operators are not defined for null pointer operands (6.5.8p5).
--
Eric Sosman
esosman@ieee-dot-org.invalid
==============================================================================
TOPIC: Stylistic questions on UNIX C coding.
http://groups.google.com/group/comp.lang.c/t/51d2b24a60d73f18?hl=en
==============================================================================
== 1 of 1 ==
Date: Mon, Mar 8 2010 12:07 pm
From: Seebs
On 2010-03-08, Nick Keighley <nick_keighley_nospam@hotmail.com> wrote:
> On 7 Mar, 22:14, Seebs <usenet-nos...@seebs.net> wrote:
>> It hasn't been, but if you can find a counterexample to the claim that
>> people generally distinguish between topic and comment, I'd love to see it.
> to be honest I just don't see this in normal english. People
> describing events often intersperse the interpreation of events or
> motivation with what happened.
That has absolutely nothing to do with the distinction between topic and
comment.
> The whole business about footnotes in formal documents is to make a
> clear distinction that isn't normally made.
But again, nothing to do with the distinction I'm talking about.
When someone says "the bear ate Bob", the bear is the topic, "ate bob" is
the comment. When someone says "Bob was eaten by a bear", Bob is the topic,
"was eaten by a bear" is the comment.
So far as I know, everyone makes this distinction. While it's not a hard and
fast rule, it's nearly always the case that the focus of discussion is the
topic of the sentence, not the comment. Thus, "the bear ate Bob" is a
statement by someone who is trying to talk about the bear, while "Bob was
eaten by a bear" is a statement by someone who is trying to talk about Bob.
They don't have quite the same semantics. One has the implication "and we
care about what the bear did", the other has the implication "and we care
about what happened to Bob".
-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
==============================================================================
TOPIC: Got stuck with quicksort code from the "Unleashed C".
http://groups.google.com/group/comp.lang.c/t/0fb91f93b991c210?hl=en
==============================================================================
== 1 of 1 ==
Date: Mon, Mar 8 2010 12:18 pm
From: Dann Corbit
In article <1a0534d1-3241-45ab-a61d-f47ec22fa002
@q21g2000yqm.googlegroups.com>, grishin-mailing-
lists@minselhoz.samara.ru says...
>
> Hello,
>
> I'm trying to cope with quick sorting algorithm (I've been doing it
> for a week at least).
> My target is to write my own version.
> I decided to learn && implement simplified algorithm first (that's why
> Vol.3 of Knuth is not a proper source).
> Now I'am absolutely confused because algorithms from Wirth's book,
> McConnel book and wikipedia seem to be not working (or weird-working
> at least) and I'm going to ask in a proper algorithms group.
>
> In addition,
> the code of simplified quick sort gives "stack overflow" too!
>
> #include <stdio.h>
>
> #define N (sizeof k / sizeof k[0])
>
> void QSORTB(int * A, int l, int r)
> {
> int loc;
>
> if (l < r) {
> int i = l,
> j = r;
> int tmp,
> pivot = A[l];
> /* Divide piles into partitions */
> for (;;) {
> while ((A[j] >= pivot) && (j > l))
> j--;
> while ((A[i] <= pivot) && (i < r))
> i++;
> if (i < j) {
> tmp = A[i];
> A[i] = A[j];
> A[j] = tmp;
> } else {
> loc = j;
> break;
> }
> }
> /* Recurse */
> QSORTB(A, l, loc);
> QSORTB(A, loc + 1, r);
> }
> }
>
>
To use the code from the book, try this (you will also need to link in
the object from cockus.c which contains the prng):
#include <stdio.h>
#define E_TYPE_SIGNED_INT
#include "allsort.h"
int main (int argc, char **argv)
{
int k[] = { 503, 87, 512, 61, 908, 170, 897, 275, 653, 426, 154,
509, 612, 677, 765, 703
};
int i;
size_t N = sizeof k / sizeof k[0];
for (i = 0; i < N; i++)
printf("%d, ", k[i]);
putchar('\n');
QSORTB(k, 0, N - 1);
for (i = 0; i < N; i++)
printf("%d, ", k[i]);
return 0;
}
/* Output:
503, 87, 512, 61, 908, 170, 897, 275, 653, 426, 154, 509, 612, 677, 765,
703,
61, 87, 154, 170, 275, 426, 503, 509, 512, 612, 653, 677, 703, 765, 897,
908,
*/
P.S.
Consider the note:
/*
Primitive quicksort. This is a bad algorithm for general purposes.
Don't use it. Use IQSORT5 instead. This thing is a bomb waiting to go
off.
*/
Further:
None of the improvements discussed in the text are included in this
primitive version, which is intended only to demonstrate the fundamental
concept of the unadorned algorithm.
The design of the book's algorithms for sorting is something like a code
generation. The idea is to approach the C++ template metaphor in C, so
that one fundamental set of algorithms can be used for any data type.
The macro:
#define E_TYPE_SIGNED_INT
generates a sort system for signed integer.
==============================================================================
TOPIC: Concerns Heathfield's and Seebach's behavior: please read
http://groups.google.com/group/comp.lang.c/t/cc475a35adc056e8?hl=en
==============================================================================
== 1 of 1 ==
Date: Mon, Mar 8 2010 12:21 pm
From: Dann Corbit
In article <RZidnbAdVJOhhw_WnZ2dnUVZ8sRi4p2d@bt.com>,
rjh@see.sig.invalid says...
>
> Chris M. Thomasson wrote:
> <snip>
>
> > IMVHO, Women have free will.
>
> Men, on the other hand...
All men are mortal.
All women are mortal.
Therefore, all men are women.[*]
Clearly then, all men have free will also.
[*] Yes, it is a very bad math joke.
==============================================================================
TOPIC: ANNOUNCE: WinGDB - debugging with GDB under Visual Studio
http://groups.google.com/group/comp.lang.c/t/caa9b97bbee41cd4?hl=en
==============================================================================
== 1 of 5 ==
Date: Mon, Mar 8 2010 12:37 pm
From: Dominic WG
Hello,
WinGDB is an extension for Visual Studio IDE allowing to use GDB
debugger. It can debug processes on remote machines running Linux (or
other Unix systems) through SSH connection, Windows programs compiled
under MinGW or Cygwin, and embedded ARM devices using OpenOCD.
Please visit our site: http://www.wingdb.com
Kind Regards,
WinGDB team
== 2 of 5 ==
Date: Mon, Mar 8 2010 12:46 pm
From: jacob navia
Dominic WG a écrit :
> Hello,
>
> WinGDB is an extension for Visual Studio IDE allowing to use GDB
> debugger. It can debug processes on remote machines running Linux (or
> other Unix systems) through SSH connection, Windows programs compiled
> under MinGW or Cygwin, and embedded ARM devices using OpenOCD.
>
> Please visit our site: http://www.wingdb.com
>
> Kind Regards,
> WinGDB team
This is incredible
These guys are selling gdb (packed in a Visual Studio plug in) at 47.5
euros per machine...
Why would anyone want to use gdb after having bought Visual Studio with
its great debugger is a mystery to me.
== 3 of 5 ==
Date: Mon, Mar 8 2010 12:51 pm
From: Dann Corbit
In article <hn3no0$e5a$1@speranza.aioe.org>, jacob@spamsink.net says...
>
> Dominic WG a écrit :
> > Hello,
> >
> > WinGDB is an extension for Visual Studio IDE allowing to use GDB
> > debugger. It can debug processes on remote machines running Linux (or
> > other Unix systems) through SSH connection, Windows programs compiled
> > under MinGW or Cygwin, and embedded ARM devices using OpenOCD.
> >
> > Please visit our site: http://www.wingdb.com
> >
> > Kind Regards,
> > WinGDB team
>
> This is incredible
>
> These guys are selling gdb (packed in a Visual Studio plug in) at 47.5
> euros per machine...
>
> Why would anyone want to use gdb after having bought Visual Studio with
> its great debugger is a mystery to me.
Even more amusing is that GDB is GPL3 and they are not distributing
source (apparently). I wonder if the FSF will get the joke.
== 4 of 5 ==
Date: Mon, Mar 8 2010 12:58 pm
From: Ian Collins
jacob navia wrote:
> Dominic WG a �crit :
>> Hello,
>>
>> WinGDB is an extension for Visual Studio IDE allowing to use GDB
>> debugger. It can debug processes on remote machines running Linux (or
>> other Unix systems) through SSH connection, Windows programs compiled
>> under MinGW or Cygwin, and embedded ARM devices using OpenOCD.
>>
>> Please visit our site: http://www.wingdb.com
>>
>> Kind Regards,
>> WinGDB team
>
> This is incredible
>
> These guys are selling gdb (packed in a Visual Studio plug in) at 47.5
> euros per machine...
>
> Why would anyone want to use gdb after having bought Visual Studio with
> its great debugger is a mystery to me.
Maybe because of "It can debug processes on remote machines running
Linux..".
Although I'd say why not use a native IDE? The answer is probably
familiarity with the tools. If I had a windows team who had to port to
a Unix environment, I'd want them as productive as possible as soon as
possible.
--
Ian Collins
== 5 of 5 ==
Date: Mon, Mar 8 2010 12:57 pm
From: Keith Thompson
Dann Corbit <dcorbit@connx.com> writes:
> In article <hn3no0$e5a$1@speranza.aioe.org>, jacob@spamsink.net says...
>> Dominic WG a écrit :
>> > WinGDB is an extension for Visual Studio IDE allowing to use GDB
>> > debugger. It can debug processes on remote machines running Linux (or
>> > other Unix systems) through SSH connection, Windows programs compiled
>> > under MinGW or Cygwin, and embedded ARM devices using OpenOCD.
>> >
>> > Please visit our site: http://www.wingdb.com
>>
>> This is incredible
>>
>> These guys are selling gdb (packed in a Visual Studio plug in) at 47.5
>> euros per machine...
>>
>> Why would anyone want to use gdb after having bought Visual Studio with
>> its great debugger is a mystery to me.
>
> Even more amusing is that GDB is GPL3 and they are not distributing
> source (apparently). I wonder if the FSF will get the joke.
<OT>
If it merely invokes gdb, and they don't ship gdb itself, there
shouldn't be a problem.
</OT>
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
==============================================================================
TOPIC: A Minor Problem With atoi() And Negative Numbers
http://groups.google.com/group/comp.lang.c/t/5218f6623a71b4c1?hl=en
==============================================================================
== 1 of 1 ==
Date: Mon, Mar 8 2010 1:30 pm
From: pete
Nick Keighley wrote:
>
> On 8 Mar, 03:12, Marcelo De Brito <nosopho...@gmail.com> wrote:
> > I
> > implemented it just to learn a little
> > bit more the C language and how
> > to pass parameters through command line. At least I already know how
> > to pass simple numeric parameters. The next objective is strings.
>
> I'm not sure I understand. The parameters passed on the command line
> *are* strings.
>
> #include <stdlib.h>
> #include <stdio.h>
>
> int main (int argc, char *argv [])
Yes.
argv is a NULL terminated array of pointers to strings.
--
pete
==============================================================================
You received this message because you are subscribed to the Google Groups "comp.lang.c"
group.
To post to this group, visit http://groups.google.com/group/comp.lang.c?hl=en
To unsubscribe from this group, send email to comp.lang.c+unsubscribe@googlegroups.com
To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.c/subscribe?hl=en
To report abuse, send email explaining the problem to abuse@googlegroups.com
==============================================================================
Google Groups: http://groups.google.com/?hl=en

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home