Table of Contents
C/C++ Programming Journal
Jan 30, 2014
STDIN - Keyboard
STDOUT - Terminal
STDERR - Terminal
Printf(“”);
Fprintf(stdout,“___”); == What Printf does.
00000000 = 0
11111111 = 255
0-255 = 256 unique values
Printf format specifiers
%d = signed int
%v = unsigned int
%c = ASCII character(char)
%s = array of character(string)
%f = floating point
%lf = double
%lu = unsigned long int
%hu = unsigned half/short int
%hhu = unsigned half half int
%x = hexidecimal
%X = hexidecimal
0x00 = hexidecimal number
binary = 0,1
octal = 0-7
decimal = 0-9
hexidecimal = 0-9a-f
Feb 6, 2014
Hexidecimal | Octal | Unsigned Decimal | Binary | Signed Decimal |
---|---|---|---|---|
0 | 00 | 00 | 0000 | +0 |
1 | 01 | 01 | 0001 | +1 |
2 | 02 | 02 | 0010 | +2 |
3 | 03 | 03 | 0011 | +3 |
4 | 04 | 04 | 0100 | +4 |
5 | 05 | 05 | 0101 | +5 |
6 | 06 | 06 | 0110 | +6 |
7 | 07 | 07 | 0111 | +7 |
8 | 10 | 08 | 1000 | -8 |
9 | 11 | 09 | 1001 | -7 |
A | 12 | 10 | 1010 | -6 |
B | 13 | 11 | 1011 | -5 |
C | 14 | 12 | 1100 | -4 |
D | 15 | 13 | 1101 | -3 |
E | 16 | 14 | 1110 | -2 |
F | 17 | 15 | 1111 | -1 |
UD | B | SD |
---|---|---|
low : 0 | low:0000 | low:-8 |
high : 15 | high:1111 | high:+7 |
qty : 16 | qty:10000 | qty:16 |
MSB - Sign Bit
0 - +
1 = -
Two's Complement:
0001
to\\
1110 #invert
+ 1 #add one
1111
01111111
0x7F
10000000
0x80
Mental Math
2 digit numbers end in 5
15^2 = 225\
square second number 1|5^2
25
time 1st number by next number up
1*2=2
=225
int input; #variable
printf(“Enter Value:”);
Scanf(“%d”,&input); #address oaddress of
Feb 27, 2014
- Today we learned more about arrays and a little bit about loops. char[10] and
- i is looping variable, i=0 is the starting value, i⇐ is loop as long as
for(i=0; i<=strlen(input); i++)
- This will make working with strings possible and make working with loops easier to work with arrays!
- At this moment i haven't completely figured out how to work with the loops but I am working on it.
- The main challenge with this course for me is learning Binary!
March 6, 2014
for loop
for(i=13, i>2, i-=3)
i-=3 means i = i - 3
while - top-driven loop - 0 or more times
do while - bottom-driven loop - 1 or more times
while(condition) - no semi colon
{
do stuff
}
do
{
do stuff
}while(condition); always does one loop first
return type - int main(int argc, char **argv)
{
int x=4;
x = square(x);
return(0);
}
y = f(x) - X is a parameter
==Function Prototype== - int square(int);
look into recursion!
March 20, 2014
fgetc(stdin); = Gets Rid Of Enter As A Input! For Char Inputs!
printf(“%.4hhd - the four leaves to blank spaces before the output the . makes the spaces zero. if it was a -4 the two spaces would be after the output. hhd means half of a half of an integer - char.
a = 41
b = 4
printf(”%.*hhd\n“,b,a); The b allows 4 zeros before the 41 because b is set to 4, variable, can change!!
==Learning More With Arrays!!
Look at program array1
- 1
#include<stdio.h> int main() { int i, scores[8], sum = 0, total; float average; printf("How big is the array?"); scanf("%d",&total); scores=(int*)malloc(sizeof(int)*total); for(i=0;i<total;i++) { printf("Enter Test Score %d/%d: ",(i+1),total); scanf("%d",(scores+i)); } for(i=0;i<total;i++) { sum = sum + *(scores+i); // or scores[i] } average = sum/total; printf("average is: %3.2f\n",average);
April 10, 2014
gcc - C - .c
g++ - C++ - .C, .cc, .c++, .cpp
look in terminal for c++ starting program.
printf(“Hello, World!\n”); in C
std :: cout « “Hello, World!” « endl; in C++
scanf(”%d“ , &a); in C
cin » a; in C++
to use cin and cout MUST INCUDE #include<iostream>
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?
MONTH Day, YEAR
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?
HPC Fundamentals Journal
MONTH Day, YEAR
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?
Jan 28, 2014
wiki.debian.org/Xen
ssh root@10.80.2.180
aptitude update aptitude upgrade aptitude search "VIM" , "Xen"- example aptitude install
hypervisor - kernel - user space
uname -a
install VIM and xen-linux-system
used Xen wiki to make Xen boot first!
vi /etc/network/interfaces
changed files according to Xen wiki
vi /etc/default/xendomains
do guest behaviour changes
restart server,
reboot
login run
xm list
xen-create-image --verbose --hostname=test --dhcp --vcpus=2 --pygrub --dist=wheezy --force
ssh root@10.80.2.197
== sign into my VM after ssh into lab46
Jan 29, 2014
Got the virtual machines up and running, had memory problem… Changed some of the ram sticks around and found the culprit and swapped it. The computer is up and running again. Re-created VM's!
Jan 30, 2014
Working with Virtual Machines, Mine being alex1. Installing packages such as Vim, bsdgames, etc. Learned how to run visual programs such as yahtzee by starting from the pod and running:
pod02:~$ ssh -X root@10.80.2.197
Created shortcuts in .bashrc such as
alias aps='aptitude search' alias api='aptitude install' alias apud='aptitude update' alias apug='aptitude upgrade'
Created Blackbeard User. Made The .vimrc and edited it.
Feb, 2014
Changed root@10.80.2.197 to root@vm04 for my sign on.
Creating Servers and Blogs Using Nginx and pybloxsom
Feb,12 2014
Finally Got My Blog Up And Running!!! Figured Out The Flavours And Have The Nice 1024px! Check out http://vm04/cgi-bin/pyblosxom.cgi
March,18 2014
Learned to create passwordless logins!!
Learned to take dumps in a new way!!
scp id_rsa.pub root@backup01:alex - copied to my root directory
cat alex » .ssh/authorized_keys - put my user into authorized keys
chmod 600 authorized_keys - changed permissions
cat authorized_keys - view the key
Continued taking dumps!!
dump -0uan -f - / | gzip -9 | ssh root@backup01 “dd of=blackbeard.dump.gz”
xm create - alex1 or wilson - Starting VM
blackbeard@router.projects.lan - arg
the type “su” to become root.
Then “screen -x” to join screen session.
April,17 2014
Subnetcalc
on lab46
%s/252/192/ will change all the 252's into 192 in the vi.
4yy copy 4 lines in vi.
cw replaces text in vi.