User Tools

Site Tools


opus:spring2013:cgaines:journal

cprog Journals

Jan 30th, 2013

GCC- GNU compiler collection

When you invoke GCC, it preprocesses, compilation, assembly, and linking.

Option - A thing that is or may be chosen

Tokens

  1. options - changes behavior of command
  2. parameters - data to be processed

unix - short options ( single characters )

microsoft - long options ( multiple characters )

prepocess - directives

       
        a computer program that modifies data to conform with the input requirements of another program
        

compile -

        collect information in order to produce something
     

assemble -

        gather together in one place for a common purpose
        

link -

        a relationship between two things or situations, esp.  where one thing affects the other
        

LAB

gcc -o numbers numbers.c
 
% takes you back to the second fprintrf
 
%X subs a hexidecimal address in (hex value)
 
%hhu   unsigned half of a half int value
 
%hu    unsigned half int value
 
%u     unsigned value
 
d is for signed values
 
8 bit - 1 byte : char
 
4 bytes : int
 
& - address of
 
%lu - subs in unsigned long int
 
%llu - subs in unsigned long long int

Feb 1st, 2013

Variable -

       name
       value
       datatype
       

freestanding environment -

       the name and type of the function called at program startup are implementation - defined.  

hosted environment -

       need not to be provided, but shall conform to the following specifications if present.
       

int main -

       the function called at program startup is named main.  The implementaion declares no prototype for this function. 
       It shall be defined with a return type of int and with no parameters:
                                        int main( void ) {/*...*/} 
       or with two parameters (referred to here as argc and argv) though any names may be used, as they are local to 
       the function in which they are dreclared
                                     int main( int argc, char * argv[ ] )
                                              {/*...*/}
       or equivalent;) or in some other implementation-defined manner.
       

Feb 6th, 2013

Character data Script

  • a is 65 but can be mapped to 'A' in ASCII
  • b is 97 but can be mapped to 'a' in ASCII
  • c is 49 but can be mapped to '1' in ASCII

Pointer fun 1

  • a contains 'a'
  • a's address is 0xFBD05F0F
  • b dereferenced contains 'a'
  • b contains 0xFBD05F0F
  • b's address is 0xFBD05F00

Pointer fun 2

  • *a is 0
  • If we uncomment that fprintf() line, what will be displayed? You receive nothing

My own script to play with, “Howdy”

#include <stdio.h>
int main()
{
        printf("Howdy Lovely Lady!\n");
        return(0);
}
  • without <stdio.h> you will recieve an error : #include expects “FILENAME” or <FILENAME>

Feb 11th, 2013

Compilation - preprocessing

             compilation proper
             assembler
             linking
             

enivronment - translation

             run execution

output - display - printf( )

             files - fprintf( )
             environment - return
                         - exit( ) from main

intput - keyboard - scanf( ) getc( )/ gets( )

             file -fscanf( ), fgetc( )/fgets( )
             environment - argc, argv
             
  
  

gcc hello.c -o hello (CMD)

gcc -o numbers numbers.c (unix)

Feb 13th, 2013

C programs - functions and declarations

cls - clears screen

cd - change dir

cd…- leave dir

cmd - info for cmd

nargs - number of arguments

nchars - number of characters

warning - somethign might not be right

error - something is not right

errors

  1. runtime
  2. syntax
  3.
  

memory

  1. data
  2. address
  

-Wall - display all Warnings

Feb 15th, 2013

C declaration - “something is”

1. datatype

  1. what kind of thing it is
  2. how much memory does it fit in

2. identifier

= assignment operator

== equivalence operator

pointerarrays.c → pointerarrays

man 3 printf —→ #include <stdio.h>

man 3 malloc —→ #include <stdlib.h>

api - application programming interface

malloc

  1. allocate raw space
  2. allocates a block of size bytes of memory, returning a pointer to the beginning of the block

function prototype - is a declaration of a function that omits the function body does specify the function's return type, name, arty, and argument types

Feb 20th, 2013

argc –> argument count

%s –> string

( char * argv[ ] ) 
  • - ( address/ pointer) reference. an address of where a string of characters are

char - built in data type

    [ ] - array
( * argv[0] )
  • - using the variable, the value at that address, dereferencing it

March 1st, 2013

Sequence

Selection

Loops

 1. for
 2. if
 3. while
 4. do 
 
 

Selections Statement

 1. if - result true or false
 2. switch    
 

default - anything that is left

GDB

  1. list (displays scripts)
  2. enter (displays more of that script)
  3. list 1 (displays beginning of the script)
  4. break _______ (sets break at desired location ) 
  5. run
  6. step -  s
  7. next -  n
  8. print 
  9. print sum
  10. set
  11. display
  12. display sum
  13. Q to quit
  14. b t - back trace - shows commands that have been done
  

March 4th, 2013

Project 3

  1. multiplier
  2. expontentiator
  printf ______ x ______ = _______
  
  
mutliplicand = ____;
multiplier = _____;
product =  0 
{
   for( prod = 1; prod < = multiplier; prod * * )
      addend1 = product;
      addend2 = multiplcand; 
      sum = addend1
   for( cnt = 1; cnt2 = addend2; cnt * * )
          sum = sum + 1;
          product = sum
}

March 6th, 2013

Conditional 
Variables
Functions 
Operators
Declarations
CLI
Compiling 
Types
Loops
Selection
Pointers
increment
add
multiplying 
exponent 
function
return type
name
parameters
input
process
output

March 8th, 2013

Functions

   1. name
   2. title
   3. input
   4. output
   5. defining - main( )
   6. calling 
         a. printf
         b. scanf
         c. malloc
         d. rand/ srand
         

Resources (from O.S. perspective)

   1. memory
   2. processes
   3. power
   4. i/o
   5. file
   6. scheduling 
   

recursion - function recalling itself over and over again

functions pointers function pointers

script mar8_2.c

#include <stdio.h>
 
void increment( int * );
void decrement( int * );
void ( * operation ) ( int * );
 
int main ( ) 
{
        int b = 37;
        operation=&increment;
        printf( "before: %u\n", b );
        operation( &b );
        printf( "after: %u\n", b );
 
        return( 0 );
}
 
 
void increment( int * num )

March 11th, 2013

Memory

  1. addresses
  2. data 
  

string

  1. ordered collection of symbols
  

functions

  1. declare - once
        a. name
        b. input type
        c. return type
  2. define - once
  3. use (call) - many times
retType funName( in1Type, in2Type,....);
retType funName( in1Type, in1Name, in2Type, in2Name,....)
{
   =funName( argName......
               or
             argValue  
 

March 13th, 2013

VBS to C Script

this = "i"
that = "o"
 
Function nott( bier )
   if bier = this then nott = that else nott = this
end Function
 
ret = msgbox( nott( this ))
char this = 'i';
char that = 'o';
 
char nott( char bier ) 
{
     if( bier = = this ) nott = that;
     else nott = this;
}
 
int ret = printf( "9c", nott( this ));

The fopen( ) function opens the file whose name is the string pointed to by path and associates a stream with it

March 15th, 2013

A struct in C programming language is a structured (record) type that aggregates a fixed set of labelled objects, possibly of different types, into a single object.

1
#include<stdio.h>
//#include<string.h>
 
int main()
{
        int i;
        char entry[80], entries = 4, junk;
 
        struct person {
                char name[80];
                int age;
                float height;
        };
 
        do {
                printf("How many people in your database? ");
                scanf("%d", &entries);
        } while (entries <= 0);
 
        struct person people[entries];
 
        for(i=0; i<entries; i++)
        {
                printf("Person %d of %d:\n", (i+1), entries);
                printf("==============\n");
 
                printf("Please enter the person's first name: ");
 
                scanf("%s", people[i].name);
//              fgets(entry, sizeof(entry), stdin);
//              strcpy(people[i].name, entry);
 
                printf("Please enter %s's age: ", people[i].name);
                scanf("%d", &people[i].age);
 
                printf("Please enter %s's height: ", people[i].name);
                scanf("%f", &people[i].height);
 
                junk = fgetc(stdin);
//              fgets(junk, sizeof(junk), stdin);
        }
 
        printf("\n\nThe names of the people are:\n");
        for(i=0; i<entries; i++)
        {
                printf("#%d: %s\t", (i+1), people[i].name);
        }
 
        printf("\n\n");
 
        printf("The full bios of the people are:\n");
        for(i=0; i<entries; i++)
        {
                printf("#%d: %s, age: %d, height: %f\n", (i+1), people[i].name, people[i].age, people[i].height);
        }
 
        return(0);
}

March 20th, 2013

  First up: The Math Library
  Then: The GD Library

March 22nd, 2013

Tokens

1) identifiers
2) keywords
3) constants
  a) integer
  b) character
  c) floating
  d) enumeration
4) string literals
5) operations

Expressions

1) pointer generation
2) primary expressions
3) postfix expressions
4) unary operators 
5) casts
6) multiplicative operators
7) additive
.
.
.
  Shapes fun: Circle of Squares
#include <stdio.h>
#include <gd.h>
#include <math.h>
 
#define PI           3.1415926535897
 
int main( )
{
   FILE *out;
   char outfile[] = "image.png";
   gdImagePtr         img;
   unsigned int       current;
   unsigned short int wide, high; 
   int degree, x, y, r = 0, red = 0, green = 0, blue = 0; 
   float radian; 
 
   wide = 800; 
   high = 800;
 
   img = gdImageCreateTrueColor(wide, high); 
 
   current = gdImageColorAllocate(img, 0x00, 0x00, 0x00);
   gdImageFilledRectangle(img, 0, 0, wide, high, current); 
 
   r = 20;
   green = 0xFF;
   for(degree = 0; degree < 1080; degree+=8)
   {
      radian = degree * (PI / 180); 
      x = (wide / 2) + r * sin(radian);
      y = (high / 2) + r * cos(radian);
      current = gdImageColorAllocate(img, 0, green, blue);
      gdImageFilledRectangle(img, x, y, x+30, y+30, current);
      r = r+4;
      blue = blue+4;
   }
 
   r = 20;
   green = 0xFF;
   for(degree = 90; degree < 1080; degree+=8)
   {
      radian = degree * (PI / 180); 
      x = (wide / 2) + r * sin(radian);
      y = (high / 2) + r * cos(radian);
      current = gdImageColorAllocate(img, red, 0, blue);
      gdImageFilledRectangle(img, x, y, x+30, y+30, current);
      r = r+4;
      blue = blue+4;
   }
 
 
   r = 20;
   green = 0xFF;
   for(degree = 180; degree < 1080; degree+=8)
   {
      radian = degree * (PI / 180); 
      x = (wide / 2) + r * sin(radian);
      y = (high / 2) + r * cos(radian);
      current = gdImageColorAllocate(img, red, green, 0 );
      gdImageFilledRectangle(img, x, y, x+30, y+30, current);
      r = r+4;
      blue = blue+4;
   }

March 25th, 2013

Polygons: Make a triangle

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gd.h>
 
#define BLACK      0
#define GRAY       1
#define VIOLET     2
#define INDIGO     3
#define BLUE       4
#define GREEN      5
#define YELLOW     6
#define ORANGE     7 
#define RED        8
#define WHITE      9
#define DARKGREEN  10
 
int main( int argc, char **argv )
{
   FILE               *out;
   char               *outfile;
   gdImagePtr         img;
   gdPoint            points[5];
   unsigned int       color[11];
   unsigned short int wide, high, x, y;
 
   if( argc ==2)
   {
        outfile = *( argv+1);
   }
   else
   {
        outfile = ( char * ) malloc (sizeof( char ) * 10);
        strcpy( outfile, "image.png" );
   }
 
   fprintf( stdout, "Using '%s' as output filename\n", outfile );
 
   wide = 800;
   high = 600;
 
   img = gdImageCreateTrueColor( wide, high );
 
   color[ BLACK ]               = gdImageColorAllocate( img,   0,   0,   0 );
   color[ BLUE ]                = gdImageColorAllocate( img,   0,   0, 255 );
   color[ GREEN ]               = gdImageColorAllocate( img,   0, 255,   0 );
   color[ DARKGREEN]            = gdImageColorAllocate( img,  51, 107,   0 );
   color[ RED ]                 = gdImageColorAllocate( img, 255,   0,   0 );
   color[ GRAY ]                = gdImageColorAllocate( img, 204, 204, 204 ); 
   color[ WHITE]                = gdImageColorAllocate( img, 255, 255, 255 );
 
   points[ 0x00 ].x = (high / 2);
   points[ 0x00 ].y = 0,
   points[ 0x01 ].x = (wide / 2);
   points[ 0x01 ].y = (high / 2);
   points[ 0x02 ].x = 0;
   points[ 0x02 ].y = (wide / 2);
   points[ 0x03 ].x = (high / 2);
   points[ 0x03 ].y = 0;
   points[ 0x04 ].x = (wide / 2);
   points[ 0x04 ].y = (high / 2);
 
   gdImageFilledPolygon( img, points, 5, color[ BLUE ]);
 
   gdImagePolygon( img, points, 5, color[ GREEN ]);
 
   out = fopen( outfile, "wb");
   gdImagePngEx( img, out, -1);
 
   fclose( out );
   gdImageDestroy( img );
 
   return( 0 );
} 

March 29th, 2013

Some times the brain is overloaded from learning so much

April 8th, 2013

logic library translation

  CSCS1240 -> CSCS1320 translation
  not
  and
  or
  Xor
  halfsum
  halfcarry
  fullsum
  fullcarry
  add Biray string to Array
  Array to string
  latch
  

String to Array Function

 1. names String2Array
 2. input string  --> 1. char array
                      2. char
                        ' \o ' terminator
 3. output array
 

Process - memory associated with a running program

Stack - local storage

Heap - global storage

Program Startup - if cmd line arg –> then open that file else create empty buffer

  1. display buffer
    1. display address offsets (0-F)
    2. display base address, 16 bytes of data in hex, same 16 bytes in ASCII
    3. input cmd

April 10th, 2013

Classes - A class is an expanded concept of a data structure: instead of holding only data, it can hold both data and functions.

       __Access Control__
           - Protected 
           - Public
           - Private

Inheritence - classes which are derived from other classes, so that they automatically include some of its “parent's” members

                class daughter: protected mother;
                
                
                

Shape (generic) —–> rectangle —–> square

April 12th, 2013

FILE *fPtr;
 
int i x;
 
fPtr = fopen( "/etc/motd", "r" );
if( fPtr = = NULL )
{
  fprintf( stdr, "Error opening file\n"); 
  exit( 1 );
}
 
for( i = 0; i < 16; i++ )
{
  fprintf( stdout, "%.2X ", fgetc(fPtr)); 
}
fprintf(stdout, "\n");
 
fclose( fPtr );
return (0);

April 17th, 2013

CLI Hex Editer

Polymorphism - is the ability to use a function name that appears in different classes (related by inheritance), without knowing exactly the class the function belongs to at compile time.

int main(              ){
 
   char a [ ] [ ];
   a = intBuffer( );
   printf( "%c", a [3][6]);
   displayBuffer (a);
   openFile( a, "hexEdit.c");
   displayBuffer(a); 
   readFile( 256, a, "hexEdit.c");
   displayBuffer(a);
}

April 22nd, 2013

#include <stdio.h>
 
int main( int a; char * * b)
{
   c = 1;
   d = 1;
   e = c&&d;
   printf( "%d", e);
   return( 0 );
}

gcc logic.c -o logic - Wall

__CMD__
 E    Edit
 S    Save
 Q    Quit
 O    Open
 N    Next
 P    Previous
 C    Clear (New)

April 26th, 2013

int * a;
float * b;
char * c;
 
int * a = 3;
      a = 3;
 
int a; 
a = 3;
a = (int)3;
 
int d( );
int *d( );
char *e( );
 
pointers are all the same size 
 
char  * s;
s = (char*) malloc(5);
* s++ = 'd';
print( "%d", a);
 
char a;
a = 3;
printf( "%d", a); 

May 1st, 2013

O.O.P.

  PIE
  Polymorphism
  Inheritance
  Encapsulation 
  
  

funcp.c

gcc funcp.c -o funcp

#include <stdio.h>
#include <string.h>
 
int inc( int a ) {
    return a + 1;
}
 
int dec( int a ) {
    return a - 1;
}
 
int main( int args, char * argv[ ] ){
    int (*count) (int);
    count = &inc;
 
    int i, n = 0;
    for( i = 0; i < 10; i++ ) {
         if( i > 5 ) count = &dec;
         n = (*count) ( n );
         printf( "%d\n", n );
    }
 
    return 0;
 
}

gcc funcp.c -o funcp

funcp.exe

May 3rd, 2013

LAST DAY OF CLASS “DUN DUN DUN” crunch time, “With the power of greyskull!”

hpc0 Journals

FEB 8, 2013

Working on and editing VM Server, Squeeze Install.

IP address, 10.80.3.11 Router giving a bit of connecting to the network, or staying connected to the network a bit of an issue.

FEB 11, 2013

This is a sample format for a dated entry. Please substitute the actual date for “Month Day, Year”, and duplicate the level 4 heading to make additional entries.

As an aid, feel free to use the following questions to help you generate content for your entries:

  • What action or concept of significance, as related to the course, did you experience on this date?
  • Why was this significant?
  • What concepts are you dealing with that may not make perfect sense?
  • What challenges are you facing with respect to the course?

Feb 11, 2013

Finished up Part 2 of the VM Server - Squeeze Install, restarted computer with no errors. Finishing up project page, and filling in OPUS.

Over all

My brain

sysprog Journals

JAN 25th, 2013

Lazy Foo Lesson 1 and 2

Reading through Lessons 1 (download SDL) and 2 (IDE Compiler).

Jan 30rd, 2013

Reading throw Lazy foo lessons 3 and 4 today. Still trying to understand most of the information, I will learn and understand this.

Feb 1st, 2013

Reading through and still trying to understand lessons 5 and 6…. Brain is being challenged which is a very good thing.

Feb 6th, 2013

Reading through lessons 7 and 8, going to have to go back through the first couple to try to reunderstand everything and take more notes and pull out my books.

Feb 8th, 2013

This is a sample format for a dated entry. Please substitute the actual date for “Month Day, Year”, and duplicate the level 4 heading to make additional entries.

As an aid, feel free to use the following questions to help you generate content for your entries:

  • What action or concept of significance, as related to the course, did you experience on this date?
  • Why was this significant?
  • What concepts are you dealing with that may not make perfect sense?
  • What challenges are you facing with respect to the course?

Feb 13, 2013

This is a sample format for a dated entry. Please substitute the actual date for “Month Day, Year”, and duplicate the level 4 heading to make additional entries.

As an aid, feel free to use the following questions to help you generate content for your entries:

  • What action or concept of significance, as related to the course, did you experience on this date?
  • Why was this significant?
  • What concepts are you dealing with that may not make perfect sense?
  • What challenges are you facing with respect to the course?

Feb 15th, 2013

Going over past lessons, trying to make things work. Reading up on background information to try to understand what I am actually dealing, at a bit of a disadvantage not knowing much about games, trying to brush up on old knowledge that has been hiding in the closet.

Over all

This is what a rough idea of what happened to me trying to study

opus/spring2013/cgaines/journal.txt · Last modified: 2013/05/06 12:30 by cgaines