(15) Fortran To C (Sina)

(15) Fortran To C (Sina) - Transition from Fortran to C (2)...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Transition from Fortran to C (2) Pointers Sina meraji Fall 2009
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Arrays in C Type Name [ Size ] One Dimensional Arrays Is the type of the values that can be stored in each element of the array Specifies the range of the indices for the subscript. Array subscripts start at 0 and end one less than the array size. Example 6 5 4 3 2 1 0 int list [ 7 ] Declaration Structure Accessing thirdNumber = list [ 2 ] 100 34 10 9 67 45 33
Background image of page 2
Arrays in C Type Name [ Size ] [ Size ] [ Size ].. Multi-Dimensional Arrays Example 9 -6 24 76 -8 5 80 34 10 13 7 41 66 int table [ 7 ] [ 2 ] Declaration Structure Accessing sixthNumber = list [ 2 ] [ 1 ] 61 51 41 31 21 11 01 60 50 40 30 20 10 00 * * Not accurate, real structure will be discussed later
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Character Strings char Name [ Size ] C Strings are defined as arrays of characters: C has no string handling facilities built in and so the following are all illegal: char first [ 50 ], last [ 50 ], full [ 100 ]; // legal first = “Arnold”; // illegal last = “Schearznegger”; // illegal full = “Mr” + first + last; // illegal
Background image of page 4
Strings There is a special library of string handling routines in <string.h> To print a string use printf with a %s control: printf (“ %s ”, name); In order to allow variable length calculation of strings the \0 (ASCII value of null) character is used to indicate the end of a string 0 41 111 119 116 40 32 50 ASCII \0 ) o w t ( 2 Character
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Functions parameter list : type 1 name 1 , type 2 name 1 , . .
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/15/2010 for the course COMP COMP 206 taught by Professor Vybihal during the Spring '04 term at McGill.

Page1 / 30

(15) Fortran To C (Sina) - Transition from Fortran to C (2)...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online