/usr/share/doc/libcnf-dev/html/node12.html is in libcnf-dev 4.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!--Converted with LaTeX2HTML 98.2 beta6 (August 14th, 1998)
original version by: Nikos Drakos, CBLU, University of Leeds
* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>Arrays</TITLE>
<META NAME="description" CONTENT="Arrays">
<META NAME="keywords" CONTENT="sun209">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<LINK REL="STYLESHEET" HREF="sun209.css">
<LINK REL="next" HREF="node13.html">
<LINK REL="previous" HREF="node11.html">
<LINK REL="up" HREF="node7.html">
<LINK REL="next" HREF="node13.html">
</HEAD>
<BODY >
<BR> <HR>
<A NAME="tex2html327"
HREF="node13.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A>
<A NAME="tex2html325"
HREF="node7.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A>
<A NAME="tex2html319"
HREF="node11.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A> <A HREF="sun209.html#stardoccontents"><IMG
ALIGN="BOTTOM" BORDER="0" SRC="contents_motif.gif"
ALT="252"></A>
<BR>
<B> Next:</B> <A NAME="tex2html328"
HREF="node13.html">Same Language - Different Compiler</A>
<BR>
<B>Up:</B> <A NAME="tex2html326"
HREF="node7.html">Representation of Data</A>
<BR>
<B> Previous:</B> <A NAME="tex2html320"
HREF="node11.html">Pointer Types</A>
<BR> <HR> <P>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION00045000000000000000"></A><A NAME="xref_arrays"></A>
<BR>
Arrays
</H2>
<P>
Although the representation of a single numerical value is unlikely to cause a
problem, the way that arrays of numbers are stored is different between
different languages. One dimensional arrays are the least problem, but even
then there are differences. In C, all arrays subscripts start at zero, and this
cannot be changed. In FORTRAN, subscripts start at one by default, but this can
be modified so that the lower bound of a dimension of an array can be any
integer. What must be remembered is that the array element with the lowest
subscript in a FORTRAN array will map on to the array element with a zero
subscript when treated as a C array. This is not a serious problem as long as
you remember it.
<P>
Multi-dimensional arrays are a well known problem since FORTRAN stores
consecutive array elements in column-major order (this <I>is</I> specified
in the FORTRAN standard) whereas other languages store them in row-major order.
For example, in FORTRAN, the order of elements in a 2 x 2 array called
<TT>A</TT> are <TT>A(1,1), A(2,1), A(1,2), A(2,2)</TT>, whereas in C this would
be <TT>A[0][0], A[0][1], A[1][0], A[1][1]</TT>.
In practice this is rarely a serious problem as long as you
remember to take account of the reversed order when writing a program. However,
when coupled with the difference in default lower bounds (zero in C, one in
FORTRAN) it is a fruitful source of bugs.
<P>
There are additional problems with FORTRAN character arrays.
This is because C handles a one dimensional FORTRAN character array as a two
dimensional array of type <TT>char</TT>, <I>i.e.</I> the FORTRAN statement:
<P>
<BLOCKQUOTE>
<TT>CHARACTER * ( NCHAR ) NAMES(DIM)</TT>
</BLOCKQUOTE>
<P>
is equivalent to the C statement:
<P>
<BLOCKQUOTE>
<TT>character names[dim][nchar]</TT>
</BLOCKQUOTE>
<P>
<BR> <HR>
<A NAME="tex2html327"
HREF="node13.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A>
<A NAME="tex2html325"
HREF="node7.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A>
<A NAME="tex2html319"
HREF="node11.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A> <A HREF="sun209.html#stardoccontents"><IMG
ALIGN="BOTTOM" BORDER="0" SRC="contents_motif.gif"
ALT="252"></A>
<BR>
<B> Next:</B> <A NAME="tex2html328"
HREF="node13.html">Same Language - Different Compiler</A>
<BR>
<B>Up:</B> <A NAME="tex2html326"
HREF="node7.html">Representation of Data</A>
<BR>
<B> Previous:</B> <A NAME="tex2html320"
HREF="node11.html">Pointer Types</A>
<BR> <HR> <P>
<!--End of Navigation Panel-->
<ADDRESS>
<I>CNF and F77 Mixed Language Programming -- FORTRAN and C<BR>Starlink User Note 209<BR>P.M. Allan<BR>A.J. Chipperfield<BR>R.F. Warren-Smith<BR>19 January 2000<BR>E-mail:<A HREF="mailto:ussc@star.rl.ac.uk">ussc@star.rl.ac.uk</A></I>
</ADDRESS>
</BODY>
</HTML>
|