strings and arrays
C strings and arrays are just pointers.
In FORTRAN, a strings and arrays are basic entities.
strings
- strings are pointers to
char
conventionally terminated by'\0'
- standard library has lots of functions
- note: the standard library is very low-level and crude. if you do a lot of string manipulation, use a string module to do it conveniently and robustly.
arrays
- the name of the array is just a pointer to the first element
a[i]
means just*(a + i)
using pointer arithmetic.- note that the notation a[i][j] suggests an array of arrays
- bounds of multi-dimensional arrays must be compile-time constants (must be passed to subroutines)
- alternatively make real array-of-arrays
- stored so that elements that differ only in last subscript are adjacent in memory.
- there are C techniques for making arrays that work as FORTRAN.