const int TWENTY_EIGHT = 28;
By adeward, 2017-09-14 10:12:28
if (type == cSTR_Integer) { 	
    type = cSTR_Integer; 
} else if (ctype == cSTR_String) {
    type = cSTR_String; 
}
By my boss, 2017-12-12 12:58:40
#557 C++ +104
int getChar(char charachter){
 int returnValue = Z;
 switch(charachter){
  case 'A': returnValue = A; break;
  case 'a': returnValue = A; break;
  case 'B': returnValue = B; break;
  case 'b': returnValue = B; break;
  case 'C': returnValue = C; break;
  case 'c': returnValue = C; break;
  case 'D': returnValue = D; break;
  case 'd': returnValue = D; break;
  case 'E': returnValue = E; break;
  case 'e': returnValue = E; break;
  case 'F': returnValue = F; break;
  case 'f': returnValue = F; break;
  case 'G': returnValue = G; break;
  case 'g': returnValue = G; break;
  case 'H': returnValue = H; break;
  case 'h': returnValue = H; break;
  case 'I': returnValue = I; break;
  case 'i': returnValue = I; break;
  case 'J': returnValue = J; break;
  case 'j': returnValue = J; break;
  case 'K': returnValue = K; break;
  case 'k': returnValue = K; break;
  case 'L': returnValue = L; break;
  case 'l': returnValue = L; break;
  case 'M': returnValue = M; break;
  case 'm': returnValue = M; break;
  case 'N': returnValue = N; break;
  case 'n': returnValue = N; break;
  case 'O': returnValue = O; break;
  case 'o': returnValue = O; break;
  case 'P': returnValue = P; break;
  case 'p': returnValue = P; break;
  case 'Q': returnValue = Q; break;
  case 'q': returnValue = Q; break;
  case 'R': returnValue = R; break;
  case 'r': returnValue = R; break;
  case 'S': returnValue = S; break;
  case 's': returnValue = S; break;
  case 'T': returnValue = T; break;
  case 't': returnValue = T; break;
  case 'U': returnValue = U; break;
  case 'u': returnValue = U; break;
  case 'V': returnValue = V; break;
  case 'v': returnValue = V; break;
  case 'W': returnValue = W; break;
  case 'w': returnValue = W; break;
  case 'X': returnValue = X; break;
  case 'x': returnValue = X; break;
  case 'Y': returnValue = Y; break;
  case 'y': returnValue = Y; break;
  case 'Z': returnValue = Z; break;
  case 'z': returnValue = Z; break;
  case ' ': returnValue = _; break;
  case '3': returnValue = B2; break;
  case '<': returnValue = TEMP; break;
  case '*': returnValue = FULL; break;
  case '|': returnValue = LINE; break;  
  case '_': returnValue = _; break;  
  case ':': returnValue = COL; break;  
  case '-': returnValue = DASH; break;  
  case ')': returnValue = BRA2; break;  
  case '%': returnValue = SMILE; break;  
  case '.': returnValue = DOT; break;    
  case '^': returnValue = COLDOT; break;      
  }
  return returnValue; //RETORNO DE INFORMAÇÃO
}

found on brazillian website

By Anonymous, 2020-02-15 00:18:29
bool IsEven(int i)
{
    if (i < 0)
        i *= -1;
        
    while(i > 0)
        i -= 2;
    
    if (i == -1)
        return false;
    else
        return true;
}

An is even function that is technically correct, but a really bad approach.

By Chris Mallery, 2017-12-12 17:34:42
void printNumber(int Number){
    while(Number>0){
        int i=Number%10;
        switch(i) {
            case 1 : cout << '1'; // prints "1",
            case 2 : cout << '2'; // then prints "2"
            case 3 : cout << '3'; // then prints "3"
            case 4 : cout << '4'; // then prints "4"
            case 5 : cout << '5'; // then prints "5"
            case 6 : cout << '6'; // then prints "6"
            case 7 : cout << '7'; // then prints "7"
            case 8 : cout << '8'; // then prints "8"
            case 9 : cout << '9'; // then prints "9"
            case 0 : cout << '0'; // then prints "0"
            default : cout<<'5'; // :|
        }
        Number=Number/10;
    }
}
By Amir Havangi, 2017-12-15 18:03:04
int my_array[] = {
#include "data.txt"
};
By Anonymous, 2017-12-12 01:45:55
// STEP 5: IF WE ARE TERRAN, THIS MATTERS, SO: LOL
void BuildingManager::checkForDeadTerranBuilders() {}
By Anonymous, 2017-12-14 12:39:17
extern "C"
{
	#include "gz.cpp"
	#include "md4.cpp"
	#include "socket.cpp"
	#include "tdlini.cpp"
	#include "tdlfs.cpp"

}

:(

By Anonymous, 2017-10-01 04:08:55
	void insert(const uint64& g)
	{
		// avoid loops for performance
		if (guid[0] == 0) { guid[0] = g; return; }
		else if (g <= guid[0]) { if (guid[3]) guid[4] = guid[3]; if (guid[2]) guid[3] = guid[2]; if (guid[1]) guid[2] = guid[1]; guid[1] = guid[0]; guid[0] = g; return; }
		if (guid[1] == 0) { guid[1] = g; return; }
		else if (g <= guid[1]) { if (guid[3]) guid[4] = guid[3]; if (guid[2]) guid[3] = guid[2]; guid[2] = guid[1]; guid[1] = g; return; }
		if (guid[2] == 0) { guid[2] = g; return; }
		else if (g <= guid[2]) { if (guid[3]) guid[4] = guid[3]; guid[3] = guid[2]; guid[2] = g; return; }
		if (guid[3] == 0) { guid[3] = g; return; }
		else if (g <= guid[3]) { guid[4] = guid[3]; guid[3] = g; return; }
		guid[4] = g;
	}
	void force_insert_front(const uint64& g)
	{
		if (guid[3]) guid[4] = guid[3]; if (guid[2]) guid[3] = guid[2]; if (guid[1]) guid[2] = guid[1]; guid[1] = guid[0]; guid[0] = g;
	}
	void remove(const uint64& g)
	{
		// avoid loops for performance
		if (guid[0] == g) { if (guid[1]) guid[0] = guid[1]; else { guid[0] = 0; return; } if (guid[2]) guid[1] = guid[2]; else { guid[1] = 0; return; } if (guid[3]) guid[2] = guid[3]; else { guid[2] = 0; return; } if (guid[4]) guid[3] = guid[4]; else { guid[3] = 0; return; } guid[4] = 0; return; }
		if (guid[1] == g) { if (guid[2]) guid[1] = guid[2]; else { guid[1] = 0; return; } if (guid[3]) guid[2] = guid[3]; else { guid[2] = 0; return; } if (guid[4]) guid[3] = guid[4]; else { guid[3] = 0; return; } guid[4] = 0; return; }
		if (guid[2] == g) { if (guid[3]) guid[2] = guid[3]; else { guid[2] = 0; return; } if (guid[4]) guid[3] = guid[4]; else { guid[3] = 0; return; } guid[4] = 0; return; }
		if (guid[3] == g) { if (guid[4]) guid[3] = guid[4]; else { guid[3] = 0; return; } guid[4] = 0; return; }
		if (guid[4] == g) guid[4] = 0;
	}
	bool hasGuid(const uint64& g) const
	{
		return g && (guid[0] == g || guid[1] == g || guid[2] == g || guid[3] == g || guid[4] == g);
	}
	bool operator<(const Lfg5Guids& x) const
	{
		// not neat, but fast xD
		if (guid[0]<=x.guid[0]) {
			if (guid[0] == x.guid[0]) {
				if (guid[1]<=x.guid[1]) {
					if (guid[1] == x.guid[1]) {
						if (guid[2]<=x.guid[2]) {
							if (guid[2] == x.guid[2]) {
								if (guid[3]<=x.guid[3]) {
									if (guid[3] == x.guid[3]) {
										if (guid[4]<=x.guid[4]) {
											if (guid[4] == x.guid[4]) return false; else return true;
										} else return false;
									} else return true;
								} else return false;
							} else return true;
						} else return false;
					} else return true;
				} else return false;
			} else return true;
		} else return false;
	}
	bool operator==(const Lfg5Guids& x) const
	{
		return guid[0] == x.guid[0] && guid[1] == x.guid[1] && guid[2] == x.guid[2] && guid[3] == x.guid[3] && guid[4] == x.guid[4];
	}
By Pussywizard, 2017-12-13 14:15:46
void function(object* thing)
{
    bool enabled = thing && thing->enabled() ? true : false;
    ...
}
By cpluspluspro, 2017-10-30 21:15:57
//count to 10
#include <iostream>
#include <string>

int main()
{
  int i = 0;
  
  beginning:
  if (i < 10) {
      std::cout << ++i << std::endl;
      goto beginning;
  }
  else goto end;

  end:
  return 0;
}
By Yoges, 2017-12-19 14:43:26
bool	vlNoExitIfZeroBytesReceived = false; //		false: can exit when receive 0 later; 	1: can not exit when receive 0 later;
By BrokenBrain, 2019-12-23 15:23:19
typedef signed int sint;
#define N 100
static int n = N;

inline int f(const int n, int& i, int* j, int t[2], int p=11)
{
    i*=i;
    (*j)--;
    
    if ( n<=0 )
    {
        cout << ::n << ">\n";
        return t[0];
    }
    else return f(n-1, i, j, t) + t[n];
}

int main()
{
    int n = 4;
    int x = 1U;
    sint y = 10;
    int (*fptr)(const int, int&, int*, int*, int) = f;

    int* t = new int[n];
    int& r = *(t+3);
    (*t) = 1;
    *(t+1) = 2;
    t[2] = 3;
    r = 4;

    int z = (*fptr)(5, x, &y, t, 12);    

    for(int i = 0; i < 2*n; i++)
    {
        if( i == n )
            continue;
        if( i > n )
            break;
        cout << t[i] << "\n";
    };
    cout << x << ", " << y << ", " << z << "\n";
    
    delete[] t;
}

This is what my professor gave as part of the final exam. The purpose of giving us this code was to get us used to seeing different ways the C++ syntax can be used and figure out what the output is.

By Anonymous, 2023-02-02 21:29:11
Entity veh = World->NewVehicle(type);
...
World->AddAnimal(veh); // insert vehicle to both landscape and world

Code for creating CAMERA object in one big AAA game engine.

By Anonymous, 2018-08-19 01:33:34
char *  dataFunc(){
    TCHAR tc[256];
    LONG tc_len = sizeof(tc);
    
    getData((LPBYTE)&tc, &tc_len);
    
    char * data = new char[tc_len];
    for(int i = 0;i < tc_len;i++)
        data[i] = tc[i];
    
    return data;
}
By Hook2, 2021-06-27 15:41:51