Post Reply 
How Do I Print to Printer With Casio VX-4 C?
08-05-2022, 07:45 AM (This post was last modified: 08-07-2022 10:35 AM by toml_12953.)
Post: #3
RE: How Do I Print to Printer With Casio VX-4 C?
(08-05-2022 03:21 AM)blackjetrock Wrote:  I don't have a VX-4 but from a C point of view, %d prints and integer not a float so looks a bit suspicious, you'll maybe get junk, or maybe Casio have a different %d.
Also, stdprn should be defined in stdio.h so you have created a local variable that hides the real stdprn when you define stdprn in that code. try taking out the

FILE *stprn;

line and add in

#include <stdio.h>

if it's not already there.

Thanks for the reply!

Casio C can't include headers like stdio.h. I did manage to print, however. Here's the program as it runs in Casio VX-4 C. It's an adaptation of the program found on page 5-5 of Learning to Program in C by Thomas Plum:

Code:
/* powdem - demonstrate power function
 */
main()
       {
       short i;
       double pw();
       extern FILE *stdprn;
       for (i = 0; i < 10; ++i)
            fprintf(stdprn, "2 to the power %d equals %.0f\n", i, pw(2., (double)i));
       exit();
       }
/* pw - return (positive) x to the power y
 */
double pw(x, y)
       double x;    /* base */
       double y;    /* exponent */
       {
       return (exp(log(x) * y));
       }

2 to the power 0 equals 1
2 to the power 1 equals 2
:
:
2 to the power 9 equals 512

Some changes I had to make:

1) Casio C needs to define functions that come after main() so I had to add

double pw();

in main()

2) User-defined functions can't duplicate predefined functions so I had to rename pow() to another name. I chose pw()

3) The statement

extern FILE *stdprn

had to be added to use a file pointer to the printer.

4) In Casio C, exit() can't take a parameter so the parameter in the book had to be removed.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: How Do I Print to Printer With Casio VX-4 C? - toml_12953 - 08-05-2022 07:45 AM



User(s) browsing this thread: 1 Guest(s)