Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > function

Reply
Thread Tools

function

 
 
Default User
Guest
Posts: n/a
 
      03-02-2008
CBFalconer wrote:

> Default User wrote:
> >

> ... snip about Cunningham trolling ...
> >
> > If he legitimately has a problem this severe, he needs to move on
> > to another endeavour. Programming is not for him.

>
> Maybe so. But I am not willing to kick him in the face. He does
> no harm.



You're entitled to believe that that's what I'm doing. It's not.



Brian
 
Reply With Quote
 
 
 
 
Kenny McCormack
Guest
Posts: n/a
 
      03-02-2008
In article <(E-Mail Removed)>,
Morris Dovey <(E-Mail Removed)> wrote:
>Kenny McCormack wrote:
>>
>> In article <(E-Mail Removed)>,
>> Richard Heathfield <(E-Mail Removed)> wrote:

>
>> >This is a really, really, reall[y] bad idea. Never, *ever* use gets(),

>>
>> Surely you exagerate.

>
>> I think using gets() is pretty innocuous.

>
>Depends. In a "proof of concept" context, it can be a handy tool
>- but in a "mission-critical" context, its use constitutes a
>failure to exercise due diligence.


Nobody is defending gets(). I'm just objecting to the stunning
level of exageration that is so common in CLC. Or, in RR's excellent
phrasing, "posturing".

 
Reply With Quote
 
 
 
 
Antoninus Twink
Guest
Posts: n/a
 
      03-02-2008
On 2 Mar 2008 at 12:56, Kenny McCormack wrote:
> In article <(E-Mail Removed)>,
> Antoninus Twink <(E-Mail Removed)> wrote:
>>On 2 Mar 2008 at 6:28, Default User wrote:
>>> CBFalconer wrote:
>>> Maybe, maybe not.
>>>
>>>> He has a mental impairment
>>>
>>> He SAYS he has a mental impairment.
>>>
>>> I killfiled him after one last attempt to get him to work
>>> systematically on one problem at a time. He ignored me.

>>
>>He sounds perfectly sane to me.
>>

>
> But I think it is perfectly clear that Default Loser is mentally impaired.
> Initially, I assumed that that was what we were discussing here.


I don't think anyone was disputing that Default Loser is mentally
impaired - that much is obvious to anyone with an IQ above room
temperature...

 
Reply With Quote
 
Antoninus Twink
Guest
Posts: n/a
 
      03-02-2008
On 2 Mar 2008 at 17:01, Default User wrote:
> CBFalconer wrote:
>
>> Default User wrote:
>> >

>> ... snip about Cunningham trolling ...
>> >
>> > If he legitimately has a problem this severe, he needs to move on
>> > to another endeavour. Programming is not for him.

>>
>> Maybe so. But I am not willing to kick him in the face. He does
>> no harm.


*blink* CBF says something sensible, and separates himself from the
nastiest manifestation of the schoolground bullying that gives the CLC
regulars their kicks... another demerit point for his dwindling Clique
Membership stock.

> You're entitled to believe that that's what I'm doing. It's not.


Yeah, sure. You're just a great guy, a totally normal and well-rounded
human being who we'd all love to have a beer with. Kick someone in the
face? You? Unimaginable.

 
Reply With Quote
 
Bill Cunningham
Guest
Posts: n/a
 
      03-03-2008
Pete,

You code and the suggestions of others hav prompted me to check fgets more
closely. I guess it adds the newline. Now the \0 Is added by my
understanding by the compiler to a string and that's the only time \0 is
added.

Bill


 
Reply With Quote
 
santosh
Guest
Posts: n/a
 
      03-03-2008
Bill Cunningham wrote:

> Pete,
>
> You code and the suggestions of others hav prompted me to check fgets
> more closely. I guess it adds the newline. Now the \0 Is added by my
> understanding by the compiler to a string and that's the only time \0
> is added.


No. In this case, it's fgets that adds the terminating null character.
The compiler is not the only entity that adds null characters. Several
standard library functions also do this.

In your case the problem is not the '\0' but the '\n' before it. Use
strchr to find and remove it before doing the comparison with strcmp.

 
Reply With Quote
 
Nick Keighley
Guest
Posts: n/a
 
      03-03-2008
as I've remarked before. Please quote properly.

On 1 Mar, 04:47, "Bill Cunningham" <(E-Mail Removed)> wrote:

> * * Might I have to change type with one of the data type changing functions
> to change char pass[10] to an arithmetic type to do a comparison?


this makes no sense. Why would you "change type" what is a "data type
changeing
function"? There's no such thing in C.

> The string
> "ded" either exists or doesn't


what?


> and if needs to evaluate that.


how can it do that?

> "Pass by
> value." someone once told me.


parameters in C are passed by value. So what?


> So many hints that a mathematician designed
> this language.


since mathematical functions don't pass by value
I don't understand why you say this

oh,

and v-plonk since you pay no attention to what you are told.

(yes I've heard of the short term memory problem)



--
Nick Keighley


 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      03-03-2008
santosh wrote:
> Bill Cunningham wrote:
>
>> You code and the suggestions of others hav prompted me to check
>> fgets more closely. I guess it adds the newline. Now the \0 Is
>> added by my understanding by the compiler to a string and that's
>> the only time \0 is added.

>
> No. In this case, it's fgets that adds the terminating null
> character. The compiler is not the only entity that adds null
> characters. Several standard library functions also do this.
>
> In your case the problem is not the '\0' but the '\n' before it.
> Use strchr to find and remove it before doing the comparison
> with strcmp.


That's the slow way. Since fgets always ends operation when it
receives a '\n', any such character is at the end of the line
(otherwise it is a maximul line, and not complete). Therefore the
code:

lgh = strlen(s);
if ('\n' == s[lgh]) s[lgh] = '\0';

will always remove it. Or get my ggets routine at:

<http://cbfalconer.home.att.net/download/ggets.zip>

and always get complete lines with the terminal '\n' removed.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.



--
Posted via a free Usenet account from http://www.teranews.com

 
Reply With Quote
 
Bill Cunningham
Guest
Posts: n/a
 
      03-03-2008

"santosh" <(E-Mail Removed)> wrote in message
news:fqe3r5$7bl$(E-Mail Removed)...

> Don't take this as an insult, but since it seems you suffer from
> attention and memory related difficulties, why don't you try a language
> that automates more things for you like, say, Python or Java or Ruby
> etc.? C is fairly low level and demands rigorous attention to details.
>
> In fact this latest post of yours is a good example. Languages like Java
> let you directly compare two strings, while you must manually do this
> in C.
>
> Just a suggestion.


I tried C++ first and wizzed through it compared to C. But I am learning
more and more. I have made progress through insights. I can stop posting to
this forum when I have a question but continue learning C the hard way. C++
is a good language. There are still big chunks of C I don't know like
structs yet. As far for mental impairments try taking 3mg of Klonopin a day.
That's what it's called in the US. Read the side effects alone of that and
you'll see you could drive around town in circles and forget an earlier
conversation from that day. I am going to read on style though. I see so
many complicated functions I don't know where to start and something like
clc is a big help.

Bill


 
Reply With Quote
 
Bill Cunningham
Guest
Posts: n/a
 
      03-03-2008

"Kenny McCormack" <(E-Mail Removed)> wrote in message
news:fqeh5a$mu7$(E-Mail Removed)...
> In article <(E-Mail Removed)>,
> Ian Collins <(E-Mail Removed)> wrote:
>>Mark McIntyre wrote:
>>>
>>> When you take on board all the tips on style, formatting and making your
>>> code legible that dozens of people have previously given you, you will
>>> be more likely to get some assisstance.

>
> Surely you exagerate. "dozens", to me, means at least 24.
>
> I'd say the number of people who've commented significantly in this
> thread is about 5, maybe 10.


My problem has been solved. I will ask clc only in extreme circumstance
when I can't solve something. Thanks to everyone I caught right onto this.
As far as style is


main(){

permisssable as long as I put the closing brace as such
} and on a line by it's self. I've seen pretty tough code. Look at linux
kernel code. I'm lost in that because of the shortcuts I don't know yet.

Bill


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Function versus pointer to function, in context of std::function,huh? Alf P. Steinbach C++ 10 07-27-2011 05:51 AM
Function pointer to void function and int function Giannis Papadopoulos C Programming 5 09-05-2005 09:06 PM
How override ALL function calls? (Is there a "function call function"?) seberino@spawar.navy.mil Python 2 08-01-2005 12:38 PM
write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter komal C++ 6 01-25-2005 11:13 AM
Passing a C++ object's member function to a C function expecing a function pointer! James Vanns C++ 7 01-21-2004 02:39 AM



Advertisments