Help: VAX C problem

Kurt Krueger kkrueger at zeus.unomaha.edu
Sat Mar 30 09:18:16 AEST 1991


Originally, I posted this on com.os.vms, but I haven't had any responses yet,
and I thought the gurus on this newsgroup could be of help.

I have been working on a simple C program to supplement a DCL program.  It is
passed two parameters: a filename and the length of the file in bytes.  It
outputs the length of time the file will take to transfer at 2400bps.  I would
have written the whole thing in DCL except that DCL can't do floating point
operations.  I wrote and compiled my program on my Amiga, and it runs fine;
however, I can't get it to run on our VAX.  I know next to nothing about C
programming on the VAX (the truth is, I know little about C, as well), and I
would be happy if someone could point out my folly.  The program is as follows:

extern int atoi();
float size, time;
int block, mins, secs;
 
main (argc, argv)
 
int argc;
char *argv[];
 
{
  int result, value();
  printf ("%s", argv[1]);
  block = value(argv[2]);
  size = block / 2;
  time = size / 0.2227;
  mins = time / 60;
  secs = time - (mins * 60);
  printf ("\t\t%d\t%d\n", mins, secs);
}
 
int value(number1)
char *number1;
{
  int convblock = atoi(number1);
}

   (I realize that a one-line function is strange, but this is only part of
what the whole program will be.)  I compiled the program on the VAX and then
linked it with the sharable vaxcrtl library as specified in the last Info-VAX.
Here is the correct output of the program as compiled on my Amiga:

RAM DISK:> test filename 55                                                   
filename                2       1                                             
RAM DISK:> test filename 45                           
filename                1       38

"Test" is the name of the program, the first parameter is "filename" and the
second is "55", which refers to the block size.  The program prints out that
the file will take 2 mins., 1 sec. to transfer (I haven't refined the xfer
times yet).  Here is the output from the VAX:

$ test filename 55
filename                30124390        24
$ test filename 45
filename                30124390        24

Obviously, something is wrong (well, this is almost plausible at 300 baud).  Is
it something to do with the floating point libraries?  I am only a computer
user by hobby, so forgive me because I know this entire post is mighty elemen-
tary to a real programmer.

Also, how do I set the tabs on the VAX?  I would like to have the first tab at
30 or 40.

Thanks in advance,

--
Sign below.  Type hard, you are making thousands of copies.
-----------------------------------------------------------------------------
Kurt Krueger | BITNET:   kkrueger at unoma1           |        //\
MBA student  | Internet: kkrueger at zeus.unomaha.edu |      \X/--\ M I G A
-----------------------------------------------------------------------------



More information about the Comp.lang.c mailing list