Hi, my name is Charlotte. So far I seem to be the only female in my computer classes… Brain will work slow at first, due to being around a four year old most of the day, and helping out with an infant. Hoping my brain gets back to full capacity soon. This semester is going to be fun.
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
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.
Character data Script
Pointer fun 1
Pointer fun 2
My own script to play with, “Howdy”
#include <stdio.h> int main() { printf("Howdy Lovely Lady!\n"); return(0); }
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)
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
C declaration - “something is”
1. datatype
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
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
argc –> argument count
%s –> string
( char * argv[ ] )
char - built in data type
[ ] - array
( * argv[0] )
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
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 }
Conditional Variables Functions Operators Declarations CLI Compiling Types Loops Selection Pointers increment add multiplying exponent function return type name parameters input process output
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 )
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
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
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.
#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); }
First up: The Math Library Then: The GD Library
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; }
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 ); }
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
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
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);
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); }
#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)
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);
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
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.
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:
Finished up Part 2 of the VM Server - Squeeze Install, restarted computer with no errors. Finishing up project page, and filling in OPUS.
Lazy Foo Lesson 1 and 2
Reading through Lessons 1 (download SDL) and 2 (IDE Compiler).
Reading throw Lazy foo lessons 3 and 4 today. Still trying to understand most of the information, I will learn and understand this.
Reading through and still trying to understand lessons 5 and 6…. Brain is being challenged which is a very good thing.
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.
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:
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:
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.