Monday, December 17, 2012

Multi-Dimensional Arrays

Tonight's lesson covered Mutli-Dimensional Arrays, pointer offsets and Buffer Overflow.  I'm not really sure how to describe what I learned.  I understand that a two dimensional array is simply an array of one dimensional arrays.  So, the more arrays you add...  The larger your multiple dimensional array.  Also, the pointer is used to select (or point at) strings and or characters in an array.  After learning the functional process of Multi - Dimensional Array and writing them with Pointer Offset Syntax.  I then learned how to code the program using Subscript Operator Syntax.  Now the Subscript Operator Syntax seems much easier and more efficient.  So, I believe I enjoy that syntax a little more.  The end of the lesson covered String Code or strcpy.h in C.

The one thing I really don't understand;
The instructor made the statement that strcpy.h was out of date and rarely used.  Now, I'm sure he has a reason for showing us the function.  Hopefully the information comes later in the course.

14.1 - Intro to Multi - Demisnsional Arrays
14.2 - Intro Multi - Dimensional Arrays II
14.3 - Intro Multi - Dimensional Arrays III
14.4 - More on Multi - Dimensional Arrays
14.5 - More on Multi - Dimensional Arrays and Intro strcpy

No test after this lesson
----------------------------------------------------------------------------------------------------------
Here is one of the written codes of the lesson

#include <stdio.h>
#include <string.h>

int main(void){
  char our_array[3][3][6];

  strcpy( our_array[0][0], "One";
  strcpy( our_array[0][1], "Two";
  strcpy( our_array[0][2], "Three";

  printf("%s \n", our_array[0][0];
  printf("%s \n", our_array[0][1];
  printf("%s \n", our_array[0][2];

return 0;
}
---------------------------------------------------------------------------------------------------------
Output: One
             Two
             Three

No comments:

Post a Comment