Diferencia entre revisiones de «C5 - Introducción a C»

De Proyectos
Ir a la navegación Ir a la búsqueda
Sin resumen de edición
Sin resumen de edición
Línea 24: Línea 24:
*funciones
*funciones
Explicar que es cada y la plantilla que se usa<br>
Explicar que es cada y la plantilla que se usa<br>
<br>
= C5.5 Keywords and punctuation =
<br>
The volatile keyword disables compiler optimization, forcing the compiler to fetch a new value each time. We will use volatile when defining I/O ports because the value of ports can change outside of software action. We will also use volatile when sharing a global variable between the main program and an interrupt service routine. It is a good programming practice not to use these keywords for your variable or function names.<br>
<br>
Lists can also be used in general expressions. Sometimes it adds clarity to a program if related variables are modified at the same place. The value of a list of expressions is always the value of the last expression in the list. In the following example, first thetime is incremented, next thedate is decremented, and then x is set to k+2.
X = (thetime++, thedate--, k+2);
<br>
<br>

Revisión del 15:13 18 feb 2015

C5.0.-Introduction - Flow Charts


Flow Charts

C5.2 Structure Organitzacion


Secciones código:

  • Descripción del programa
  • Autores
  • Fecha
  • Includes
  • main


There are four sections of a C program as shown in Program 5.2. The first section is the documentation section, which includes the purpose of the software, the authors, the date, and any copyright information. When the software involves external hardware we will add information about how the external hardware is connected. The second section is the preprocessor directives. We will use the preprocessor directive #include to connect this software with other modules. We use diamond braces to include system libraries, like the standard I/O, and we use quotes to link up with other user code within the project. In this case the uart module is software we wrote to perform I/O with the universal asynchronous receiver/transmitter (uart). We will discuss modular programming in great detail in this class. The third section is global declarations section. This section will include global variables and function prototypes for functions defined in this module. The last section will be the functions themselves. In this class we will use the terms subroutine, procedure, function, and program interchangeably. Every software system in C has exactly one main program, which defines where it begins execution.

There are two types of comments. The first type explains how to use the software. These comments are usually placed at the top of the file, within the header file, or at the start of a function. The reader of these comments will be writing software that uses or calls these routines. The second type of comments assists a future programmer (ourselves included) in changing, debugging or extending these routines. We usually place these comments within the body of the functions. The comments on the right of each line are examples of the second type.

C5.4 Functions


Se añade una nueva sección al código:

  • prototype
  • funciones

Explicar que es cada y la plantilla que se usa

C5.5 Keywords and punctuation


The volatile keyword disables compiler optimization, forcing the compiler to fetch a new value each time. We will use volatile when defining I/O ports because the value of ports can change outside of software action. We will also use volatile when sharing a global variable between the main program and an interrupt service routine. It is a good programming practice not to use these keywords for your variable or function names.

Lists can also be used in general expressions. Sometimes it adds clarity to a program if related variables are modified at the same place. The value of a list of expressions is always the value of the last expression in the list. In the following example, first thetime is incremented, next thedate is decremented, and then x is set to k+2.

X = (thetime++, thedate--, k+2);