Compaq Visual Fortran: A Guide to Creating Windows Applications

Appendix A: Overview of C for Fortran Programmers

Overview

As with Fortran 90/95, C is a free-format language. The end of a statement is signified by means of a semicolon ( ;), and a user can have multiple statements on one line separated by semicolons, or a single statement may go over a number of lines. Comments may be everything between the pair of symbols /* and */.

In C, the parts of a program that are enclosed by two curly brackets {} are called blocks. The start of a block, {, may be on the same line as the expression where the block starts, or it may be on the start of the following line and aligned with the other statements in the block. The conclusion of the block is signaled by the block-end curly bracket } positioned on its own and indented slightly to the right.

Unlike Fortran, C does not differentiate between subroutines and functions; C has only functions. The structure for a program written in C is made up of many functions, one of which must always be present and named main. There can be only one main for each program. Every function must contain at least one block to define the start and the end of the function. In the following example, the word void preceding the function main indicates that there is no return value from this function:

   void main ()   /   ********************************************************   *   Code...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Programming Languages
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.