0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
try
{
fIn = fopen(cszFileName, "rb");
if (fIn == 0)
throw (std::string("Can not open file: ") + cszFileName);
if (!ParseFile(fIn, pLookup))
throw (std::string("Bad file format. File: ") + cszFileName);
throw std::string("");
}
catch (std::string& e)
{
if (fIn != 0)
{
fclose(fIn);
fIn = NULL;
}
if (e.length() != 0)
{
throw std::exception(e.c_str());
}
}
Исправленный говнокод
guest ,
04.08.2009 (Updated 24.03.2018 )
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
try
{
fIn = fopen(cszFileName, "rb");
if (fIn == 0)
{
throw (std::string("Can not open file: ") + cszFileName);
if (!ParseFile(fIn, pLookup))
throw (std::string("Bad file format. File: ") + cszFileName);
throw std::string("");
}
}
catch (std::string& e)
{
if (fIn != 0)
{
fclose(fIn);
fIn = NULL;
}
if (e.length() != 0)
{
throw std::exception(e.c_str());
}
}
Просто говнокод
guest ,
04.08.2009 (Updated 24.03.2018 )
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#define KOEF_A 31415926
#define KOEF_B 27182818
#define INIT_VAL 3091976
unsigned long dVal;
unsigned char rnd()
{
unsigned long r = dVal*KOEF_A + KOEF_B;
int m = dVal % 8;
dVal = r >> m;
dVal++;
return (unsigned char)(dVal & 0xFF);
}
void Encode(void* data, int len)
{
if( len < 1 ) return;
for( int i = 0; i < len; i++ )
{
int xval = rnd();
((char*)data)[i] ^= xval;
}
}
используется для шифрования и дешифрования файла
guest ,
04.08.2009 (Updated 24.03.2018 )
0
1 2
byte* pSomeArr = new byte[nArrLen];
auto_ptr<byte> bAutoPtr(pSomeArr); // auto delete on exit
Защита от утечек памяти! =)
guest ,
31.07.2009 (Updated 24.03.2018 )
0
Непроходимая игра.
1 мячик. 2 Платформы слева и справа.
Это код перемещения платформы робота по y.
guest ,
28.07.2009 (Updated 24.03.2018 )
0
1 2 3 4 5
int main()
{
...
return rand();
}
Иногда даже вылетают ошибки!
guest ,
28.07.2009 (Updated 24.03.2018 )
0
1 2 3 4 5 6 7 8
if (a > 5)
...
else if (a < 5)
...
else if (i == 5)
...
else
printf ("Сегодня плохой день!");
Плохой день)))
guest ,
27.07.2009 (Updated 24.03.2018 )
0
1 2 3 4 5 6 7 8 9
void intaIs1intbIs2intcisAplusBHWNDwndIsgetWnd...()
{
int a = 1;
int b = 2;
int c = a + b;
HWND wnd = getWnd();
...
}
Тут все ясно
guest ,
27.07.2009 (Updated 24.03.2018 )
0
1
if (a) b = true; else b = false;
В реале видел. Тупил минут 5, пытаясь понять внутренний смысл этой конструкции
guest ,
16.07.2009 (Updated 24.03.2018 )
0
1 2 3 4 5 6 7 8
class Par_host_port
{
private:
std::string vdata;
public:
//...
char* get () { return (char*)vdata.c_str (); }
};
char const* превращается... Превращается char const*... В char*!
guest ,
15.07.2009 (Updated 24.03.2018 )