Skip to content

Instantly share code, notes, and snippets.

@guyhughes
Created April 16, 2016 20:01
Show Gist options
  • Save guyhughes/190bf6843439327db4dc707cd9c5534d to your computer and use it in GitHub Desktop.
Save guyhughes/190bf6843439327db4dc707cd9c5534d to your computer and use it in GitHub Desktop.
#include <iostream>
int main ()
{
int z;
for (int i = 39; i < 43; i++){
std::cerr << "i: " << i << std::endl;
for (int j = 29; j < i-9; j+=3){
z = i % j;
std::cerr << "z: " << z << std::endl;
if (z % 2 == 1){
for(int k=0; k < i-j; k+=3){
std::cerr << "k: " << k << std::endl;
std::cout << "*" << k << std::endl;
}
std::cout << "#" << j << std::endl;
std::cout << "&" << i << std::endl;
}
}
}
return 0;
}
#include <iostream>
void f();
void g(int,int);
class Picture { public: int a; };
int g1=0;
static int g2=0;
Picture z;
int main(void)
{
Picture* b = new Picture;
for(int i=0; i < 2; ++i)
f();
g(99,77);
for(int i=0; i < 2; ++i)
f();
g(55,44);
}
void g(int stack_x, int stack_y)
{
g1++, g2++;
std::cout << "g1: " << g1 << "\tg2:" << g2 << std::endl;
x;
}
void f()
{
Picture a;
static int* x // a static pointer (data segment)
= new int(0); // to a dynamically allocated int (heap)
int y; // automatic (function call stack)
static int z; // a static int (data segment)
std::cout << "x is " << *x << std::endl;
std::cout << "g1 is " << g1 << std::endl;
std::cout << "g2 is " << g2 << std::endl << std::endl;
(*x)++, g1++, g2++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment