BasicMath C++

6 Oct

#include<iostream>
#include<cstdio>
#define cout std::cout
#define endl std::endl

void ErrorMsg(){
cout<<“<number> <+-x/> <number><ENTER>”<<endl;
}

int main(int argc, char *argv[]){
double num1 , num2;
if(argc == 4){
if(argv[2][0] == ‘+’ || argv[2][0] == ‘-‘||argv[2][0] == ‘x’||argv[2][0] == ‘/’){
if(scanf(argv[1],”%lf”,&num1)&&sscanf(argv[3],”%lf”,&num2)){
switch (argv[2][0]) {
case ‘+’:
cout << num1+num2<<endl; break;
case ‘-‘:
cout << num1-num2<<endl; break;
case ‘x’:
cout << num1*num2<<endl; break;
case ‘/’:
cout << num1/num2<<endl; break;
default: ErrorMsg(); break;
}
}

}

}
else{
ErrorMsg();
}

return 0;
}

memory address walkthrough

2 Oct

ATTENTION STUFF:

 

int  => 4 bytes

char => 1 byte

1 byte =8 bits

 

std::cout<<(int)*((char*)(v))<<‘ ‘<<\
(int)*((char*)(v)+1)<<‘ ‘<<(int)*((char*)(v)+2)<<‘ ‘<<\
(int)*((char*)(v)+3)<<std::endl

It, actually, means, the pointer moves to next byte

 

Git stuff

14 Sep

Git set up:

$ git config –global user.name

$ git config –global user.email

checking status:

$git status

tracking new files :

$ git add

Committing changes:

$git commit -m

$git commit -a -m

removing files:

$git rm

(git commit )

viewing the commit history:

$git log

back to *****:

edit: mark , copy , paste

$git checkout ******

getting new branch:

$git checkout -b “name”

switch:  $git checkout name

Merging:

$git merge name

git clone url

git remote

git push (origin)  (master)

git pull (origin) (master)