Q
quarkLore
Following program is erroneous as I am passing a float as int. The
output is
---
|
V
Int f is 0 float f is 0.000000
[return value 32 error number 0]
float f is 3.000000 int f is 0
[return value 33 error number 0]
---
In the first print why is the second value not right? I am using 'gcc
version 3.2.2' on Linux.
The error should be contained only in first value as it will try to
read float as integer.
Is it totally unpredictable?
#include <stdio.h>
#include <errno.h>
extern int errno;
int main()
{
int n;
float f=3.0f;
/* Print f as int and then float */
n = printf("\nInt f is %d float f is %f\n",f,f);
printf("[return value %d error number %d]\n",n,errno);
/* Print f as float and then int */
n = printf("\nfloat f is %f int f is %d \n",f,f);
printf("[return value %d error number %d]\n",n,errno);
return 0;
}
output is
---
|
V
Int f is 0 float f is 0.000000
[return value 32 error number 0]
float f is 3.000000 int f is 0
[return value 33 error number 0]
---
In the first print why is the second value not right? I am using 'gcc
version 3.2.2' on Linux.
The error should be contained only in first value as it will try to
read float as integer.
Is it totally unpredictable?
#include <stdio.h>
#include <errno.h>
extern int errno;
int main()
{
int n;
float f=3.0f;
/* Print f as int and then float */
n = printf("\nInt f is %d float f is %f\n",f,f);
printf("[return value %d error number %d]\n",n,errno);
/* Print f as float and then int */
n = printf("\nfloat f is %f int f is %d \n",f,f);
printf("[return value %d error number %d]\n",n,errno);
return 0;
}