1 / 196

POWER PMAC C/C# TRAINING

DELTA TAU DATA SYSTEMS, INC. welcomes you to. POWER PMAC C/C# TRAINING. Please make yourself comfortable (grab some coffee and a donut ). The instructor will be with you shortly. Day 1: Introduction to C Day 2 : Overview of PPMAC C Programs Safe Programming Techniques

Télécharger la présentation

POWER PMAC C/C# TRAINING

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. DELTA TAUDATA SYSTEMS, INC. welcomes you to POWER PMAC C/C# TRAINING Please make yourself comfortable (grab some coffee and a donut). The instructor will be with you shortly.

  2. Day 1: • Introduction to C • Day 2: • Overview of PPMAC C Programs • Safe Programming Techniques • Shared Memory Pointers (pshm) • Day 3: • User Buffer Pointers (pushm) and Data Types • I/O Memory Pointers (piom) • Gate Pointers • Custom Servo Algorithms • Custom Phase Algorithms • Custom Trajectory Generation Algorithms • Day 4: • Capture/Compare Interrupt Service Routine • CfromScript • Custom Threading • Debugger • Day 5: • Introduction to C# • Introduction to Visual Studio C# • Basic GUI Design • Synchronous Communication • Asynchronous Communication Power PMAC Training Delta Tau Data Systems, Inc.

  3. Power PMAC Training Delta Tau Data Systems, Inc.

  4. C programs have the following basic structure: #include <stdio.h> // Header file for standard I/O communication // May have other #includes here also int main(void) // “main” is the first function to run when the program starts { // Left curly brace to open the function // Any main body code, which probably will consist // of just calling several other functions return 0; // The function’s return value comes after “return” } // Right curly brace to close the function C Code • #include This preprocessor directive will add whatever code is located in the header file within the < > brackets as code usable by the rest of the functions listed in this source code file • int main(void) This is a function receiving no argument (hence “void”) and returning 0. It is the first function to run in your program and will call all other functions if needed. Main is of type int – more on types and functions later. The computer’s operating system calls this function first. • return 0; • Every function returns a value to the function , program, or O/S that called it. The type of this data is the same as the function’s type; in this case, the type is int since we defined main as int main. Note that all statements must end in a semicolon. Power PMAC Training Delta Tau Data Systems, Inc.

  5. Comments can come in two forms in C: // This is a single-line comment, indicated by two forward slashes /* This is a paragraph comment initiated by a forward slash and asterisk concluded by asterisk forward slash */ C Code In the above code: Everything after the // will be not compiled. Everything between the /* and the */ will not be compiled. Power PMAC Training Delta Tau Data Systems, Inc.

  6. There are several different fundamental data types that variables can use in C: • int / long • Signed integer values. In PPMAC, 32 bits, ranged ±231. • unsigned int / unsigned long • Unsigned integer values. In PPMAC, 32 bits, ranged 0 to 232 . • long long • Signed integer values. In PPMAC, 64 bits, ranged ±263. • unsigned long long • Unsigned integer values. In PPMAC, 64 bits, ranged ±264. • char Represents a single alphanumeric character of 8 bits. When assigning character values to these variables, you must use single quotes; e.g.: char MyChar; MyChar = 'c'; // sets MyCharequal to the character 'c' C Code Power PMAC Training Delta Tau Data Systems, Inc.

  7. Note Note • float • Floating point single precision values. In PPMAC, 32 bits, ranged 3.4e±38. • double • Floating point double precision values. In PPMAC, 64 bits, ranged 3.4e±308. In PPMAC, all Q-Variables (csglobals) and P-Variables (globals) are doubles, so be sure you use a double-type variable if reading from these types of variables. Power PMAC Training Delta Tau Data Systems, Inc.

  8. Note • const • Place this before your data type (e.g. constint) to indicate that this variable’s value will not change. Must be initialized in the declaration. • volatile • Place this before your data type (e.g. volatile int) to tell the compiler not to optimize this variable but to read its memory address every time, even in indefinite loops. This qualifier is recommended when pointing to a memory register that could be modified by hardware or an interrupt service routine (e.g. with a Digital I/O card, Analog I/O card, or Axis Interface card). • extern • Place this before your data type (e.g. extern int) to tell the compiler you are just declaring that this variable will exist later in the code, but do not yet allocate memory for it (which is called “defining” the variable). Power PMAC Training Delta Tau Data Systems, Inc.

  9. Define a variable by typing the data type and then your variable’s name thereafter; e.g.: #include <stdio.h> void main(void)// Note: This function is a void type, not requiring a return { intMyInt; // Define your variable MyInt as type int int MyInt2=6; // Can initialize the var to a value this way also } C Code Set your variable to a value by typing the variable name, then =, then the value; e.g.: MyInt = 5; // Set your variable to 5 C Code You can use other variables in your expression as well; e.g.: #include <stdio.h> void main(void) { int MyInt1,MyInt2; // Can declare multiple variables on one line MyInt1 = 5; // Set your variable to 5 MyInt2 = MyInt1; // Set MyInt2 equal to MyInt1 } C Code Power PMAC Training Delta Tau Data Systems, Inc.

  10. An expression is any group of variables, constants, function calls, and operators that evaluates to a numerical value; e.g.: inta,b; a = 5; // 5 is an expression consisting of only a numeric literal b = 4*5; // 4*5 is an expression with two numeric literals and an operator a = a*b; // a*b is an expression with two variables and an operator a = sin(b); // sin(b) is an expression with a function call and a variable // calling the sine trigonometric function (requires math.h) C Code Power PMAC Training Delta Tau Data Systems, Inc.

  11. Operators can be used in creating expressions in C. There are 7 categories of operators, the first of which is Arithmetic Operators, used for arithmetic: Power PMAC Training Delta Tau Data Systems, Inc.

  12. Note Note This category is for comparing the value of two numbers logically: Power PMAC Training Delta Tau Data Systems, Inc.

  13. This category is for comparing the truth state of two numbers: Power PMAC Training Delta Tau Data Systems, Inc.

  14. This category is for comparing the logical state of all of the bits in a value: Power PMAC Training Delta Tau Data Systems, Inc.

  15. Note These operators consist of two operators combined into one: Power PMAC Training Delta Tau Data Systems, Inc.

  16. Note This category is for using pointers, structures, and arrays in C: Power PMAC Training Delta Tau Data Systems, Inc.

  17. When a series of operators are found in an expression, their order of operations is as follows: Power PMAC Training Delta Tau Data Systems, Inc.

  18. In C, the conversion between data types is not done automatically, unlike in PMAC Script. Therefore, when you are creating expressions involving multiple data types, you must manually cast each data type to a common data type. Otherwise, data could be lost; e.g.: int a; double b,c; a = 5; b = (double)a*3.0; // Must cast “a” to double before using with “b” c = 3.0/((double)a); // Must case “a” to double before using with “c” C Code b = a*3.0; is actually acceptable, but we cast “a” to double to be explicit. c = 3.0/((double)a); is completely necessary; otherwise, the fractional value would be truncated, and you would get the result of 0.0 in your double, c! Power PMAC Training Delta Tau Data Systems, Inc.

  19. Note A function is a subroutine that can accept any number of inputs and produce one single output. You must give the function a name, define its output type, have it return a value the same type as the output type, and define its input arguments: doubleMyFunction(int Input1, double Input2, double Input3) { double Output; Output=(double)Input1*Input2-Input3; return Output; } C Code The purpose of a function is to create an easy way for the programmer to perform the same routine many times without reproducing the same code each time. To call the above function, just use its name, pass it arguments, and optionally store its output value, e.g.: double result; result=MyFunction(5, 6.35, 7.3); // Store output into “result” MyFunction(3,2.3,5.8); // Can also call the function without storing output C Code Power PMAC Training Delta Tau Data Systems, Inc.

  20. Typically, a function should be placed beneath the main() function and then a prototype of the function must be placed above main(). A prototype is just the function’s declaration with a semicolon after it. From the function on the previous slide, the prototype is as follows: double MyFunction(int Input1, double Input2, double Input3); // Prototype C Code The whole program would look like this then: #include <stdio.h> double MyFunction(int Input1, double Input2, double Input3); // Semicolon! int main(void) { double result; result=MyFunction(5, 6.35, 7.3); } double MyFunction(int Input1, double Input2, double Input3) // No semicolon! { double Output; Output=(double)Input1*Input2-Input3; return Output; } C Code Power PMAC Training Delta Tau Data Systems, Inc.

  21. All variables defined within functions (including within main()) are considered “Local” variables because only that function has access to those variables, e.g.: double ExampleFunction(double Input1) { double local1=4.1,local2=3.5; // These are local variables return local1*local2+Input1; } C Code local1 and local2’s “scope” is just within the ExampleFunction function. However, any variables defined outside of functions are called “Global” because their scope is universal; that is, any function can use them, e.g.: double Global1=43.5; // This variable is globally accessible double ExampleFunction(double Input1) { double local1=4.1,local2=3.5; // These are local variables return local1*local2+Input1*Global1; // There is no need to define Global1 locally inside this function // before using it because it was defined globally outside the function } C Code Power PMAC Training Delta Tau Data Systems, Inc.

  22. You can perform logic checks through if statements whose basic syntax is shown below: if(condition) // if condition is true { // execute a set of actions } else // condition is false { // execute another set of actions } C Code Here is an example: if(a>b) // if condition is true { a=5;// execute a set of actions b=6; } else // condition is false { a=6;// execute another set of actions b=5; } C Code Power PMAC Training Delta Tau Data Systems, Inc.

  23. If the action after if or else is only a one-line statement, you may omit the curly braces: C Code if(condition) // if condition is true // execute one action statement else // condition is false // execute another actionstatement Here is an example: if(a>5) // if condition is true a = 10;// execute one action statement else // condition is false a = -1;// execute another action statement C Code If you are only checking a condition and setting one variable, you may use the shorthand Ternary Conditional (a ? b : c), e.g.: a = (a>5) ? 10 : -1; // Exactly equivalent to the code above C Code When using Ternary Conditionals, the data type of b (10 in this example) and c (-1 in this example) must be the same data type as a. Power PMAC Training Delta Tau Data Systems, Inc.

  24. A while loop repeats indefinitely until its condition is satisfied. The condition is checked before the loop iteration executes. Its syntax is as follows: while(condition) { // perform actions } C Code For example, the below loop repeats until ctrbecomes 5: ctr=0; while(ctr<5) { ctr++; // Increment “ctr” until ctr becomes 5 } C Code Power PMAC Training Delta Tau Data Systems, Inc.

  25. do…while loops are similar to while loops, but one iteration of the loop will execute before the condition is checked at all. The syntax is as follows: do { // execute tasks } while(condition); C Code For example: ctr=0; do { ctr++; } while(ctr<5); C Code Power PMAC Training Delta Tau Data Systems, Inc.

  26. A for loop is intended for use when you know the exact number of times a loop needs to execute. Its syntax is as follows: for(counter=starting_value; continuation_condition; counter_incrementing) { // execute actions } C Code For example: int counter; int a=1; for(counter=0; counter<10; counter++) { // Loop 10 times a*=2; // Each iteration, multiply a by 2 } C Code counter<10 indicates that we want this loop to execute 10 times. Power PMAC Training Delta Tau Data Systems, Inc.

  27. The following syntax for(counter=0; counter<10; counter++) { // execute actions } C Code Is equivalent in function to this syntax: counter=0; while(counter<10) { // execute actions counter++; } C Code Power PMAC Training Delta Tau Data Systems, Inc.

  28. Two very important flow control statements are break and continue. • break • When used, will cause the presently executing loop to stop completely, moving on to the code after the loop’s ending. For example: • continue • When used, will cause the loop to exit at this very point in execution and immediately begin the next iteration of the loop. For example: intctr=0,StopFlag; while(ctr<10) { ctr++; if(StopFlag==1) break; // Exits the loop right here } C Code intctr=0,PauseFlag; while(ctr<10) { if(PauseFlag==1) continue; // Skip this iteration of the loop ctr++; } C Code Power PMAC Training Delta Tau Data Systems, Inc.

  29. A switch statement permits you to define actions to perform based off of a discrete number of known integer states (each one called a case, with one default case) that a variable (which also must be integral) can take. This is more efficient and more convenient to program than a giant chain of if-else statements. The syntax is as follows: switch(variable) { case First_Case_Number: // Actions to take break; case Second_Case_Number: // Actions to take break; // … Put any number of additional case statements here default: // Default runs if variable does not take any of the // values specified in the other cases // Actions to take by default break; } C Code Power PMAC Training Delta Tau Data Systems, Inc.

  30. Example: switch(a) // Check a’s state { case 1: // Actions to take if a equals 1 break; case 2: // Actions to take if a equals 2 break; default: // Executes if a is not 1 or 2 // Actions to take by default break; } C Code Power PMAC Training Delta Tau Data Systems, Inc.

  31. A structure takes the data type struct. It is a group of variables. You can put whatever standard data type variable inside a struct and access that variable as a field or member of the struct. For example, let’s create a vector structure to contain x, y, and z components of a vector: struct vector { double x; // x component double y; // y component double z; // z component } C Code You must define this new data type above your main() function, e.g.: Then, you can instantiate a variable using this data type as follows, for example: struct vector{double x,y,z;} int main(void) { /// code return 0; } C Code struct vector position; // “position” is our new vector structure C Code Then, to access the fields within the structure, just type the structure’s name (vector), a period (.), then the name of the field, e.g.: position.x=13.0; // write 13.0 to the x field of the position vector C Code Power PMAC Training Delta Tau Data Systems, Inc.

  32. A typedef can be used to rename a data type to a more convenient name to make using it as a data type for new variables easier. For example, in the struct example on the previous slide, it was slightly inconvenient to write struct vector position to define the new variable. We can rename struct vector to just VECTOR, e.g.: typedefstructvector { double x; // x component double y; // y component double z; // z component } VECTOR; C Code Now, to use the new data type for a variable: VECTOR position; // “position” is our new position vector // of type struct vector C Code Power PMAC Training Delta Tau Data Systems, Inc.

  33. You can rename variables or subroutines with the preprocessor directive #define. The syntax is #define NewNameOldName. For example: C Code #define MyConstant 5 // Redefine “5” as “MyConstant” #define MyOtherConstant 9.38 // Redefine “9.38” as “MyOtherConstant” #define AddTwoNumbers(x,y) (x+y) // Redefine “(x+y)” as “AddTwoNumbers” Now you can refer to them by name in your code; e.g.: int a=5; a *= MyConstant; // Exactly the same as multiplying a by 5 double b=6.78; b *= MyOtherConstant; // Exactly the same as multiplying b by 9.38; double c=3.5; c = AddTwoNumbers(b,c); // Exactly the same as “c=b+c” C Code Power PMAC Training Delta Tau Data Systems, Inc.

  34. An enum is used to create a set of named integer constants called an “enumeration set.” The advantage of creating this set through enum rather than #define is that the compiler generates the numbers for you; you do not need to keep track of which constants have been used up already. Also, they obey scoping rules, so you can only access the enum values within the scope of where you defined it, and all enum tags (the name of the enumlist). All enums are of type int. Here is an example of using enum: enumerrcode // Defines an Enumeration Type { NoError, HomingError, ComputationError, OutOfBounds }; enumerrcode Mtr1ErrCode; // Create an enum type variable Mtr1ErrCode=NoError; // Set it to one of the errcode values int flag=HomingError; // Can also set ints to the errcode values C Code Power PMAC Training Delta Tau Data Systems, Inc.

  35. You can also specify which number on which to start. Otherwise they start at 0. For example: enum weekdays { Sunday=1, Monday, // Becomes 2 Tuesday, // Becomes 3 Wednesday, // Becomes 4 Thursday, // Becomes 5 Friday, // Becomes 6 Saturday // Becomes 7 }; C Code Power PMAC Training Delta Tau Data Systems, Inc.

  36. A union is like a struct except that all of the variables share the same memory space. The compiler allocates enough memory for the largest data type in the union. Unions can be used in many ways, but one of the most useful ways is to create a “Generic” data type. Think of union as an actor that can have many personalities (and wear many masks) but is actually the same person. Power PMAC Training Delta Tau Data Systems, Inc.

  37. To create a “Generic” data type that can be a double, float, or an int in the same memory space, you can use union with struct and typedeftogether: union DFI // This union contains a double, a float, and an int { double d; float f; inti; }; enumTypes // This creates a list of enumerations for the three above data { // types DOUBLE, FLOAT, INT }; typedefstructDFI_Union_Handler // This is a structure containing { // a union variable we declared above, and a “status” variable // to let us know what kind of variable we want the union to be at the time union DFI VALUE; enum Types TYPE; } VAR; C Code Power PMAC Training Delta Tau Data Systems, Inc.

  38. Now to access the data in the union, just specify the data type in TYPE and you can read/write the value in VALUE just like a structure (using the . operator): VAR MyVar; // declare your variable MyVar.TYPE=DOUBLE; // set the variable’s type to double MyVar.VALUE.d=533.95; // set the variable to your desired value C Code Power PMAC Training Delta Tau Data Systems, Inc.

  39. Now that you know about functions, prototypes, globals, structures, unions, and enums, we can expand the general outline of a C program further: #include <stdio.h> // Header file for standard I/O communication // May have other #includes here also // structures, enums, unions, globals // Function Prototypes int main(void) // “main” is the first function to run when the program starts { // Left curly brace to open the function // Any main body code, which probably will consist // of just calling several other functions return 0; // The function’s return value comes after “return” } // Right curly brace to close the function // Functions C Code Power PMAC Training Delta Tau Data Systems, Inc.

  40. Pointers are variables which contain addresses of memory registers. When dereferenced (with the * operator) , the pointer can access (read from or write to) the value inside the address of the memory register whose address the pointer contains. To make a pointer to a certain data type, just add a star after the data type, or add the star to the variable name itself. Example: int *iptr; // Declare an integer pointer. int* iptr2; // Declare another integer pointer C Code Then, give the pointer an address to which to point either by telling it directly the numerical constant address, or by referencing (using the & operator on) another variable; e.g.: int *iptr; // Declare an integer pointer. int a=7; // Declare an arbitrary integer (a non-pointer integer), set to 7 iptr=&a; // Reference a, telling iptr to point to a’s address *iptr=10; // Dereference iptr, changing the value of a to 10 C Code Power PMAC Training Delta Tau Data Systems, Inc.

  41. Let’s look at it graphically. Let’s define an integer like before: int a=7; // Declare an arbitrary integer (a non-pointer integer) C Code Think of the integer a as a house. It has an address (&a), just like all the houses in your neighborhood. The house also contains a number of people, in this case 7, which is the value of a. Contents of the house: a Address of the House: a a &a Power PMAC Training Delta Tau Data Systems, Inc.

  42. So let’s define an integer pointer to point to a: int *iptr; // Declare an integer pointer. iptr=&a; // Reference a, telling iptr to point to a’s address *iptr=10; // Dereference iptr, changing the value of a to 10 C Code iptr=&a means “I want iptr to point to a’s address.” *iptrnow returns the same thing as a; that is, if I want to know the contents of a, I just read *iptr. If I want to change the contents of a, I just write to *iptr. Contents of the house: a = *iptr Address of the House: &a,whichiptrcontains &a a Power PMAC Training Delta Tau Data Systems, Inc.

  43. You can define a series of variables in a group and index them numerically. For example: int b[3]; // Creates an array of three ints C Code b is the name of the array. You can access each element of the array with an index: b[0] is the 0th element, b[1] is the 1st element, b[2] is the 2nd element. Now, since the symbol b represents an array rather than an individual value, b and &b both represent the memory address of the first element of the array (the base of the array), a+1 represents a[1]’s memory address, and so on. Imagine that the barray consists of three houses on a block, all living on “bStreet”: b+0 b+2 b+1 b[0] b[1] b[2] Power PMAC Training Delta Tau Data Systems, Inc.

  44. You can access the elements of an array through pointers as well. Knowing that b is the base address of the b array, b+1 is b[1]’s address, and b+2 is b[2]’s address, we can dereference (with *)these addresses to read from or write to the array’s elements, just like we dereferenced &a in the previous example: int b[3],*iptr; iptr=b; // or iptr=&b, same thing *(iptr+ 0)=5; // same as b[0]=5, and same as *(b+0)=5 *(iptr+ 1)=3; // same as b[1]=3, and same as *(b+1)=3 C Code b+0 b+2 b+1 *(b+0) *(b+2) *(b+1) Power PMAC Training Delta Tau Data Systems, Inc.

  45. A string is just a char array. You can initialize it without specifying the length: char MyString[]=“This is my string.”; C Code Or, you can give it a length and fill the contents of the string later: char MyString[256]; // arbitrarily pick 256 for the length of the string MyString=“This is now the string’s contents.”; C Code In strings, the last element of the array is always the null character, ‘\0’. You must consider this when determining the length of your array. You can also initialize strings as a char* pointer, e.g.: char *MyString=“This is my string.”; C Code In the above example, MyString now becomes a char array of length 19 (length of the array’s contents you specified + 1 for the null character). However, if you define the string as a char*, you cannot define the string at a later time unless you allocate memory for it using malloc() and later free the memory with free(). We will discuss this later. There are numerous functions you can use for manipulating strings, found in string.h, whose function references you can look up online. Power PMAC Training Delta Tau Data Systems, Inc.

  46. You can make an array with multiple dimensions in C as well. Example of a two dimensional array (a matrix): C Code The matrix’s elements are shown graphically as in a matrix form as follows: int c[3][3]; // Make a 3x3 matrix called “c” You can even add more dimensions, e.g.: int d[3][3][3]; // Make a 3-element array (called “d”) of 3x3 matrices C Code Array’s elements are shown graphically as in a matrix form as follows: Power PMAC Training Delta Tau Data Systems, Inc.

  47. Normally, a function can only return one value, and this value is of the same data type as the function’s return type. However, you can have a function receive an argument by reference, rather than value, and then directly modify the argument’s value by means of a pointer. For example, let’s say we want a function to modify three variables whose scope is defined in the calling function. int main(void) { int a=2,b=4,c=35; modify_three_numbers(&a,&b,&c); // Must pass by reference, using & return 0; } void modify_three_numbers(int *arg1, int *arg2, int *arg3) { *arg1*=2; // Must dereference argument with * *arg2*=3; *arg3*=4; } C Code Power PMAC Training Delta Tau Data Systems, Inc.

  48. You can pass an array to a function and modify the original array’s contents (not a copy of the array’s contents) inside that function. You need not specify the length of the array being input to the function you call, although you are permitted to do so. Example: void populate_array_with_ones(int array[], int length); Prototype // This prototype is necessary that you may call the function from main() int main(void) { intMyArray[25]; populate_array_with_ones(MyArray,25); // Pass the array’s name, not // &(array name) to the function we wrote (below) return 0; } void populate_array_with_ones(int array[], int length) // This function receives the array and its length as arguments { // “array” is a local variable that receives the address of the 0th element // of the array whose name you pass it (MyArray in this example) // Modify the array here just as though it were in the calling function intctr; // Allocate an indexing variable for looping purposes for(ctr=0;ctr<length;ctr++) // cycle through all of the array’s elements array[ctr]=1; // and make them all “ones” } C Code Power PMAC Training Delta Tau Data Systems, Inc.

  49. If you want to pass a multidimensional array, you have to specify the span of all of the dimensions except the first: void populate_matrix(int input[][15], intNumRows, intNumCols); void populate_matrix_array(int input[][43][6], intNumRows, intNumCols, intNumMatrices); int main(void) { intMyMatrix[12][15],MyArrayOfMatrices[8][43][6]; populate_matrix(MyMatrix); // Just pass the array’s name populate_matrix_array(MyArrayOfMatrices); return 0; } void populate_matrix(int input[][15], intNumRows, intNumCols) { // Modify the array here as though it were in the calling function } void populate_matrix_array(int input[][43][6], intNumRows, intNumCols, intNumMatrices) { // Modify the array here } C Code Power PMAC Training Delta Tau Data Systems, Inc.

  50. Note Let’s say you want to declare an array, but you do not know how long it needs to be until later. Here, you must use the functions malloc() and free(). Let’s say our original array looks like the following: int array[size]; C Code However, you want to declare “size” at runtime, not compile time; i.e., “size” is a variable, not a constant. To do this, you can use this construction: int *array; array=(int *) malloc(size*sizeof(int)); C Code Then, you can index the array as normal, e.g.: array[0]=5; array[1]=6; // etc. C Code Since this data is pushed on the stack, not the segment, a possibility of memory leaks occurs; therefore, when you are done with the array, you must free it. Memory leaks are where allocated memory is not freed before the program returns. For example, to safely deallocate the array just created (and normally return from the program): free(array); C Code Power PMAC Training Delta Tau Data Systems, Inc.

More Related