From nobody@FreeBSD.org  Sun Mar 18 14:38:06 2001
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id C8D3637B71A
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 18 Mar 2001 14:38:06 -0800 (PST)
	(envelope-from nobody@FreeBSD.org)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.1/8.11.1) id f2IMc6t11966;
	Sun, 18 Mar 2001 14:38:06 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200103182238.f2IMc6t11966@freefall.freebsd.org>
Date: Sun, 18 Mar 2001 14:38:06 -0800 (PST)
From: gh@raditex.se
To: freebsd-gnats-submit@FreeBSD.org
Subject: Error in the printf-function.
X-Send-Pr-Version: www-1.0

>Number:         25904
>Category:       misc
>Synopsis:       Error in the printf-function.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Mar 18 14:40:00 PST 2001
>Closed-Date:    Mon Mar 19 02:04:13 PST 2001
>Last-Modified:  Mon Mar 19 02:05:02 PST 2001
>Originator:     Gran Hasse
>Release:        4.2
>Organization:
Raditex AB
>Environment:
Ordinary c-program
>Description:
The printf function seems to mix up whats a pointer and whats
a value... ?
>How-To-Repeat:
Run this program

#include <stdio.h>
#include <stdlib.h>

main()
{
    int * Var;
    float Value;
    int IntVar;

    Value = 2.4;
    IntVar = 4;

    Var = malloc(4);
    
    *Var =  Value ;
   
    /* Why is it like this? - explain */

    if( 0 )
    printf("Value is %f \n", Value );
    printf("  Var is %f \n", Var );

    if( 1 )
    printf("Value is %f \n", Value );
    printf("  Var is %f \n", Var );

    *Var = IntVar;

    if( 1 )
    printf("Value is %d \n", IntVar );
    printf("  Var is %d \n", *Var );


}


>Fix:

>Release-Note:
>Audit-Trail:

From: David Malone <dwmalone@maths.tcd.ie>
To: gh@raditex.se
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: misc/25904: Error in the printf-function.
Date: Sun, 18 Mar 2001 23:39:28 +0000

 On Sun, Mar 18, 2001 at 02:38:06PM -0800, gh@raditex.se wrote:
 
 > >Description:
 > The printf function seems to mix up whats a pointer and whats
 > a value... ?
 
 You must pass the correct types to printf if you want it to
 do something sensible. Each time you used "%f", which means
 "I am about to pass a float or a double", but you passed a
 mixture of other things.
 
 If you're a beginner C programmer then I'd suggest that you
 turn on some more compiler warnings, which will give about
 this:
 
 	gcc -pedantic -ansi -W -Wall file.c
 
 Also, you might want to consult the C FAQ at:
 
 	http://www.eskimo.com/~scs/C-faq/top.html
 
 and try reading the newsgroup comp.lang.c.
 
 	David.
State-Changed-From-To: open->closed 
State-Changed-By: dwmalone 
State-Changed-When: Mon Mar 19 02:04:13 PST 2001 
State-Changed-Why:  
Seems to be due to misues of printf. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=25904 
>Unformatted:
