Formula Sheet PDF - Summary Mechatronics 1 PDF

Title Formula Sheet PDF - Summary Mechatronics 1
Author Charlotte Power
Course Mechatronics 1
Institution University of Sydney
Pages 1
File Size 197.2 KB
File Type PDF
Total Downloads 38
Total Views 146

Summary

This is the one sided A4 page of notes that I took into my MTRX 1702 exam. In involves some formulas and key points about the course. ...


Description

Scop Scope e Dec Declarat larat laration ion vvss D Defini efini efinition tion Local variable: automatic extent - its lifetime Declaration: refers to the specification of a variable or defined to block. At the point it is defined, function, in particular its name and type. In function – header. Can do many times memory is allocated for it on the “stack” Definition: also involves the allocation of storage. Actual Extent: lifetime of a variable function. Comes after main.c . Variables – tell compiler Program/external/global: visible in all files what type. Only once. #define: has file scope Static: memory is not destroyed when scope of Definition: int value variable is exited. Declaration: extern int value Extern: gets variable out of scope and uses it in scope Byte Size Sizess of TTyp yp ypes es Bit O Opera pera perations tions File Handlin Handlingg Open Fgets(buf, sizeof(buf), stdin); char * data_filename = “myfile.txt” FILE *data_fp = fopen(data_filename,"r");

while ((c == getc(fp)) != EOF) putc(c, stdout); fclose(data_fp); Mem Memory ory Area Con Constan stan stantt Data Reg Region ion

Info

Mana Managed: ged: Static Ex Extent tent

Compiler Read-writable. Memory allocated when program starts. Variable released back when program quits Compiler Allocate storage for local variables. Automatic extent. Memory allocated when variable is defined. Released when variable goes out of scope. Compiler

Mana Managed: ged: Stack

Mana Managed: ged: Heap

Mana Managed: ged:

ME MEMORY MORY

Free Nod Node e s in Lin Linked ked Li st

PassPass-By By By--Re Referen feren ference ce & Ca Callll-By-Va -Value lue PBR: Sending address. CAN change values of variables outside function. CBV: only returned value gets passed back to calling function. Variables stay within functions. Con Const st Const int *p = &I Can’t change value of contents (p = &i valid *p = i invalid) int *const p = &i Can’t change address Fun Function ction ctionss Assert(): Checks an expression and terminates if false. Good for checking logical errors. Strncmp(str1, str2, size): returns 0 if str1 == str2. Strlen(): returns number of bytes (discounting ‘\0’). Strcpy(dest, string): Struc Structt

& Link Linked ed List

Read only. String constants and other data known at compile time.

Used for dynamic storage. Controlled via stdlib functions. Used during program runtime. Stack is faster than heap. Can cause errors since not checked by compiler. Programmer

Char *str = “Hello” Char *str[] = “Hello Int a1[] = {1, 2, 3, 4} Int a2[] = {5, 6, 7} Int *pa = {a1, a2}

Figure 2 Add New Node to End

Figure 1: Cycle Through Nodes

Stings and Arrays - read-only string constant - read-writable, array initialised by char const - array of integers - array of integers - array of pointers to integer arrays

Dyna Dynamic mic Me Memory mory

Debugging: 1.Stabilise the error 2.Locate source of error 3.Fix the defect 4.Test the fix 5.Look for similar errors

Pre-p Pre-proc roc rocesso esso essor: r: Header-file inclusion Symbolic constant definition Definition of macros Conditional compilation

Strat Strategies: egies: Top-down Bottom-up Risk-oriented Featureoriented Hybrid of above

Con Control trol FFlow: low: Sequential Conditional (decision) Loop (iteration)...


Similar Free PDFs