mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Trond Myklebust <trond.myklebust@fys.uio.no>
To: mahamuni ashish <ash_lkp@yahoo.co.in>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Floating Point Issue
Date: Thu, 27 Sep 2007 14:25:04 -0400	[thread overview]
Message-ID: <1190917504.6668.52.camel@heimdal.trondhjem.org> (raw)
In-Reply-To: <109515.18343.qm@web7805.mail.in.yahoo.com>

On Thu, 2007-09-27 at 12:41 +0100, mahamuni ashish wrote:
> I have small code....
> 
> #include <stdio.h>
> #include <string.h>
> 
> int main()
> {
> float f= 1256.35;
> char ch[4];
> 
> printf("\n1. f : %f",f);
> memset(ch,'\0',strlen(ch) );
> printf("\n2. f : %f",f);
> return 0;
> }
> 
> Expected output is
> 1. f : 1256.35
> 2. f : 1256.35
> 
> But I am getting the output
> (on windows)
> 1. f : 1256.35
> 2. f : 0.000000
> 
> (on Linux)
> 1. f : 1256.35
> segmentation fault
> 
> why?

'cos 'strlen(ch)' isn't defined until you've initialised ch. If you swap
that line out with 'memset(ch, '\0', sizeof(ch))' then it will work.

Not a kernel bug, and hence not appropriate material for this list.

Trond


  parent reply	other threads:[~2007-09-27 18:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-27 11:41 mahamuni ashish
2007-09-27 15:17 ` Jan Engelhardt
2007-09-28  2:32   ` WANG Cong
2007-09-27 15:21 ` Xavier Bestel
2007-09-27 15:29 ` Al Viro
2007-09-27 18:25 ` Trond Myklebust [this message]
2007-09-27 20:53 ` linux-os (Dick Johnson)
2007-09-27 21:01   ` Jan Engelhardt
2007-09-28  8:31 ` Bernd Petrovitsch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1190917504.6668.52.camel@heimdal.trondhjem.org \
    --to=trond.myklebust@fys.uio.no \
    --cc=ash_lkp@yahoo.co.in \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®