User Tools

Site Tools


opus:fall2014:zgolden:journal

C/C++ Programming Journal

August 29, 2014 (week one)

The first week of classes are over :-o. This semester is going to require a lot more attention during classes and studying on top of working. Programming is not a simple thing to learn. Matt expressed it perfectly when he compared programming language to foreign languages! Sure you may be able to learn some quick pointers but to be able to put it all together with being sloppy takes time and knowledge. I'm hoping that taking C/C++ along with Object and Structure class at the same time won't be a problem. I see a lot of similarities already mainly when at the lab section on C/C++. Joe was using a lot of the vocabulary and motions Matt took the previous days. Setting up the repositories along with cloning randomly type coded was interesting to learn but I would be lying if I wasn't confused. Just one misplaced character can completely defeat what you are trying to accomplish. I'm hoping the next couple weeks are not so much easier but clearer to me so I can not feel so lost and begin to gain some confidence that I can do programming and do it well!

Guide to setting up chat:

  • irssi
  • /server irc
  • /join csci or lab46
  • Alt 1- go to commands, Alt 2- csci, Alt 3, lab 46
  • Ctrl+A then D- detach from chat
  • Screen -r- reattach

September 4, 2014 (week two)

The second week of class is over and went smoother then the last. I'm still having a hard time once in awhile remembering how to open files and compile the files. However I know in time these actions will become second nature. Matt went over the code we wrote Tuesday. He explained more of the functions as well as altering the program to show us what certain functions do.

File actions

  • open/create file- nano filename
  • compile- gcc -o filename filename.c
  • bring up program- ./filename

Notes

  • 73- integer (set number)(int)
  • 3.14- float (irrational)
  • 'r','c','d','w'- character (single)(char)
  • “hello”- array of characters (string)
  • \0- null terminal used at end of string
  • Pointer- *
  • %p-displays the address of the variable
  • %d- used for a signed integer (sign is the ability to go below zero)
  • %u- used for a unsigned integer (can't go below zero)(fixed storage)
  • d=&c sets d to the same storage set as c
  • 0x3D- hexidecimal
  • 073- base number
  • %x or %X- 4 bytes hex value
  • %c- displays as an acii table (asciitable.com)

September 11, 2014 (week three)

status cprog will show attendance, opus, and projects

Scanf()

  • must leave the \n new line identifier out
  • first perimeter type the data type you intend to scan
  • next perimeter you would use the & operator to assign the scanned info to a variable

F0r()

  • loop
  • good for counting

Place holders

  • int (integer values) uses %d
  • float (floating point values) uses %f
  • char (single character values) uses %c
  • character strings (arrays of characters, discussed later) use %s

Array

  • specify a variable that can be indexed
  • helps us be lazy/efficient so that we can write one code for changing variables instead of writing each one out seperately

September 18, 2014 (week four)

Mental Math

  • 65^2=⇒ 5^2=25 6(6+1)=42=⇒ 4225
  • 32×11=⇒ 3 (3+2)=5 2=⇒ 352
  • 100000-72386=⇒ 7+2=9 2+7=9 3+6=9…..=⇒27614

Coding shortcuts

  • i=i+1 =⇒ i++; or ++i;
  • i=i-1 =⇒ i–; or –i;

September 25, 2014 (week five)

Basecounterflex led up to data types and ranges, see helper.c program. Shows the value of the different variables.

signed and unsigned variables are 8 bits

bits unsigned signed 000 0 +0 001 1 +1 010 2 +2 011 3 +3 100 4 -4 101 5 -3 110 6 -2 111 7 -1

signed

  • 0 = positive
  • 1 = negative
  • two's complement- inverting the number and adding one
  • char- -128 till 127
  • %hd

unsigned

  • 0-7
  • char- 0-255
  • %hu

Programs

  • shortint.c
  • shortint2.c

Logic

  • &-bitwise AND
  • |- bitwise inclusive OR
  • ^- bitwise exclusive OR

Day of week program assigned due October 1

October 2, 2014 (week six)

Makefile

  1. collection of actions instructing Make how to perform the action.
  2. make help to bring up actions
  3. use “make” to make things

CMD arguements

  • argc- argument counter (at least one)
  • argv- argument vector, an array of strings
  • first argument must be int, second must be char

Program

  • CLA.c
  • funtion.c

Pipe Math assignment

  • running/creating one of each program (numbers, maths, bases)
  • scan for input but doesn't have to be user guided
  • coverts ascii to number using atoi(3), value=atoi(argv[1]);
  • cd pipemath to access files

Numbers- 4, Maths- divideby, Bases- tobase7

If statement vs Else if statement

  • if else will stop once one of the statements become true
  • if statements will continue to run throughout the whole process even if first statement was true
  • Else is more efficient for CPU usage

Readability vs write-ability

  • Readability helps you use less comments because the code is organized in a way the reader can tell the steps
  • write-ability involves more comments due to the need of explaining most the steps
  • functions are more readability action, can be broken down to make it easier to understand

October 9, 2014 (week seven)

switch (variable)

  • may be more useful then if, else if, else functions.
  • Used for exact values.
  • not really needed but good to know
{
     case0:
     thing;
     break; \\need break otherwise it keeps going case to case until a break
     
     case 1:
     thing;
     break;
}

Program

  • funwithgraphics.c

Pipe Math Assignment

  • now moved to October 22
  • plus adding an enhancement to base counting

Gather notes from 10/9 (Thursday class)

October 24, 2014 (week eight)

Scope

  • Global- seen by all funtions
  • Local- within a certain function

Function

  • name
  • return type
  • data type

Program

  • functions.c

Knowledge test on October 30

October 30, 2014 (week nine)

What we can do with files?

  • open
  • read
  • write
  • append
  • create
  • remove/delete
  • seek

Things to remember

  • fopen returns a pointer,address, to the file
  • know what you want to do with your files (read, write, read & write, etc.)

File pointers

  • stdin
  • stdout
  • stderr

Programs

  • funwithfiles.c
  • funwithfiles2.c
  • datafile.txt

Skill assessment Thursday!

November 6, 2014 (week ten)

Access Control

  • public -accessible outside the class (like a struct)
  • private -can't use until we get to inheritance (later in semester)
  • private -accessed only from within the class

Function overloading

  • allows for functions to share the same name as long as some part, like return type or its parameters, differ.

Instantiation

  • creating an instance of a class
  • if there is a constructor, upon instantiation, that constructor will run.

Destructor

  • freeing up resources allocated to an object when an object goes out of scope or is explicitly released.

compile C++ programs

  • g++ -o filename filename.cc

accessor methods

  • allows us to control the private class data

Program

  • rectangle.cc
  • rectangle2.cc

Inheritance

  • inheritancenotes.cc

November 13, 2014 (week eleven)

Programs

  • Directory: SinglyLinkedNode
    • create.cc
    • create.o
    • libSinglyLinkedNode.a
    • next.cc
    • next.o
  • Directory: Node
    • create.cc
    • create.o
    • libnode.a
    • value.cc
    • value.o
  • Directory: inc
    • SinglyLinkedNode.h
    • node.h
  • Directory: src/cprog
    • nodefun.cc

Node.h

start → 7 → NULL [start = new SingliyLinkedNode (7)]

tmp/tmp2 → NULL

start → 7 → 39 → NULL [start → setnext (SinglyLinkedNode (39)]

start → 7 → 39 → NULL [tmp=start→ getNext()]

             ^
             '-tmp

tmp2→ 73 → NULL [tmp2 = newSingliyLinkedNode (73)] (separate nodes atm)

            tmp2            
            '

start→ 7 → 39 → NULL

            ^
            '-tmp
            tmp2 
            '

start → 7 → 73 → 39 → NULL [start→ setNext(tmp2);]

                   ^
                   '-tmp
                   

Compiling: g++ -o nodefun nodefun.cc -Iinc -LSinglyLinkedNode -lSinglyLinkedNode -Lnode -lnode

Reminder

  • -L links to directory
  • -l links to the library
  • upper and lower case sensitive

November 20, 2014 (week twelve)

Program

  • graphicsbreak2.c
  • myfile.png
opus/fall2014/zgolden/journal.txt · Last modified: 2014/11/18 15:49 by zgolden