Advanced Minds

  • Decrease font size
  • Default font size
  • Increase font size
  • default color
  • red color
  • green color
FireBoard
Welcome, Guest
Please Login or Register.    Lost Password?
fprintf c [Aztec-C] (1 viewing) (1) Guests
Go to bottom Post Reply Favoured: 0
TOPIC: fprintf c [Aztec-C]
#8590
Gio (Visitor)
Click here to see the profile of this user
Birthdate:
fprintf c [Aztec-C]  
Okay. I am using the K&R book. I'm quite literally on section 1.2. According to the Aztec-C docs, the printf() function is supposed to handle displaying floats.. but it doesn't seem to. I compiled the following:
Code: :
   #include <stdio.h   main()   {        float fahr, celsius;        float lower, upper, step;        lower = 0;   /* lower limit of temperatuire scale */        upper = 300; /* upper limit */        step = 20;   /* step size */        fahr = lower;        while (fahr <= upper) {            celsius = (5.0/9.0) * (fahr-32.0);            printf( %3.0f %6.1fn , fahr, celsius);            fahr = fahr + step;        }   }    
The output this gives me is a single column of f's. If I change the program to use ints instead of floats, it gives me the expected output. - Gio
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#8591
Bill Buckels (Visitor)
Click here to see the profile of this user
Birthdate:
fprintf c [Aztec-C]  
Okay. I am using the K&R book. I'm quite literally on section 1.2. According to the Aztec-C docs, the printf() function is supposed to handle displaying floats.. but it doesn't seem to. I compiled the following: The _link_er is your friend. Change the way the _link_er line in the make file resolves your libraries. _link_ to M.LIB first (the Math Library) first. Remember floats should only be used where required as a matter of saving memory in your program and if their use is not required don't use them or _link_ to all the libraries with the M.LIB first. Remember to include the appropriate header for the particular library functions that you call (math.h in this case if you needed to call the functions directly) Change -lSYSIO -lg2 -lc -ls -lm -lSYSIO -lg2 -lc -ls -lm To -lSYSIO -lg2 -lm -ls -lc -lSYSIO -lg2 -lm -ls -lc The printf and format used by printf in the math library are compiled with different preprocessor directives as shown way below: Here's the math library: lb 3.40a 5-29-86 **DIR**     asin        atan        floor       pow log random      sin         sinh        sqrt        tan tanh exp         fprintf     printf      sprintf     fformat fscanf scanf       sscanf      fscan       fabs        flt65 math ftoa        atof        flt2        flt1 You will note that the ftoa function is required in the MATH LIBRARY version of this. If I do not want to haul around that particular piece of baggage every time I call printf then I do what I did by _link_ing to clib first. Here's the std c library lb 3.40a 5-29-86 **DIR**     tmpfile     perror      fdopen      fopen fseek scanf       gets        getchar     fscanf      fgets agetc fread       getw        getc        puterr      printf puts putchar     fprintf     fputs       aputc       fwrite putw putc        getbuff     setbuf      tmpnam      mktemp ungetc getenv      calloc      malloc      access      data execp exec        isatty      open        casecvt     lseek read write       rename      geteof      seteof      seteofu getfinfo getfinfu    setfinfo    setfinfu    getiob      setiob mkdir rsvstk      brk         sbrk        crt0        shmain exit close       un_link_      fixnam      fixnamu     setprfx getprfx strshft     device      exitu       devtab      gdev ioctl ctime       asctime     gettime     localtim    time system atoi        atol        qsort       sscanf      scan sprintf format      ctype       swapmem     setmem      rindex strrchr strncat     fstswt      tmpsav      strequ      index strchr movmem      move        strncpy     strncmp     strcat strcmp strcpy      istack      lmath       strlen      swit math shift       lshift      stack       sup         interp fldstar flt         longs       setjmp x
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#8592
Gio (Visitor)
Click here to see the profile of this user
Birthdate:
fprintf c [Aztec-C]  
Aha! Changing the _link_er worked perfectly, thanks! I'll have to read up on the _link_er today. - Gio
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#8593
Bill Buckels (Visitor)
Click here to see the profile of this user
Birthdate:
fprintf c [Aztec-C]  
Aha! Changing the _link_er worked perfectly, thanks! I'll have to read up on the _link_er today. - Gio
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#8594
Gio (Visitor)
Click here to see the profile of this user
Birthdate:
fprintf c [Aztec-C]  

What's even better from my point of view is that you understood what to do.
Well, you did make it quite clear. - Gio
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop
brak autoryzacji brak autoryzacji sprawdz autoryzacje wymiana linkow 905
forex market info evening news urban legends news station thailand tours