SRL Archive - SRL Member Goodies

[C++]Membership Response Generator


Sin

2012-05-31 10:44:48

I was having a lot of fun whipping this up :p
It'll allow you to generate responses, i'll add a few more features, but this was done at school haha.

How to copy/paste in CMD -

Right Click > Mark > Highlight copy text > Hit enter.


Edit v1.1 - Will now save response to a text file.

Tickyy

2012-05-31 12:22:57

Huh, ran it, didn't get the point of making this (no offense).

[XoL]

2012-05-31 12:36:03

Lol its like me… but automated :P

putonajonny

2012-05-31 13:04:07

I see you also decided to learn C++, was that for school or just for fun? It looks well made, next up… something that analyses the code and generates that message without having to put in options (I know this exists but if you want to stretch yourself this would be a good thing to make)

superuser

2012-05-31 14:10:24

I suggest you to read C++ faq lite.

Sin

2012-05-31 15:27:22

From: R4nd0m
Lol its like me… but automated :P

I know, it's based off your responses :3

From: putonajonny
I see you also decided to learn C++, was that for school or just for fun? It looks well made, next up… something that analyses the code and generates that message without having to put in options (I know this exists but if you want to stretch yourself this would be a good thing to make)


Thanks :D
And I did it for fun, it wasn't for school, i'll also consider what you said :D
From: superuser
I suggest you to read C++ faq lite.


Will do , thanks :)

Frement

2012-05-31 15:45:17

Also, standards please!

Examples:
static bool once = false;
if ( !once )
{
DisassembleShader( pDevice, "C:\ShaderDisassembly.dat" );
once = true;
}
HRESULT __stdcall _BeginScene( LPDIRECT3DDEVICE9 pDevice )
{

__asm { pushad }

if( !pFont )
{
D3DXCreateFontA( pDevice, 12, 0, FW_NORMAL, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Verdana", &pFont );
GenerateTexture( pDevice, &texGreen , D3DCOLOR_ARGB( 255, 0, 255, 0 ) );
GenerateTexture( pDevice, &texRed , D3DCOLOR_ARGB( 255, 255, 0, 0 ) );
}

__asm { popad }

return ( (HRESULT (__stdcall*)(LPDIRECT3DDEVICE9) ) x_BeginScene->Trampoline() )( pDevice );
}

std::cout << "My text" << std::endl;

Sin

2012-05-31 15:47:59

Ahh.
So a cout would follow this format?

cout<< "my text" << myString << endl; 

Frement

2012-05-31 15:53:07

From: Shay
Ahh.
So a cout would follow this format?

cout<< "my text" << myString << endl; 


Yes, except using a namespace std is wrong, you should always use std::cout and std::endl. I know all the beginner tutorials always use it, but get used to using cout etc with the prefix.

superuser

2012-05-31 15:57:18

From: Shay
Ahh.
So a cout would follow this format?

cout<< "my text" << myString << endl; 


It's just the use of stream-operators.

E.g.

 #include <iostream>

class Foo
{
public:
friend std::ostream& operator<< (std::ostream &o, Foo const &f);

...

private:
int bar;
};

std::ostream& operator<< (std::ostream &o, Foo const &f)
{
return o << f.bar;
}

int main()
{
Foo f;

std::cout << "My Foo object: " << f << std::endl;
...
}

Sin

2012-05-31 15:57:27

I don't quite understand.
So at the beginning of every program, I have to declare std::cout?

superuser

2012-05-31 16:05:03

From: Shay
I don't quite understand.
So at the beginning of every program, I have to declare std::cout?


No, you include

#include <iostream>

which contains lots of streaming-stuff, like std::cout. That std-prefix is just a namespace what to use.

For example:

namespace Foo {
class Bar {
};
}

int main()
{
Foo::Bar f;
}

So, you are using standard-library's (std) function/class cout by typing std::cout.

Sin

2012-05-31 16:08:46

Ahhh.
So. What's wrong with calling namespace? Is it just frowned upon?
Also, is there a way to save the output to a file?

superuser

2012-05-31 16:25:16

From: Shay
Ahhh.
So. What's wrong with calling namespace? Is it just frowned upon?
Also, is there a way to save the output to a file?


Most C++ users are quite happy reading std::string, std::vector, etc. In fact, seeing a raw vector makes me wonder if this is the std::vector or a different user-defined vector.

using namespace std; I am always against. It imports all sorts of names into the global namespace and can cause all sorts of non-obvious ambiguities.

Here's some basic file output things:

#include <iostream>
#include <fstream>

int main ()
{
std::ofstream myfile;

myfile.open("example.txt");
myfile << "Writing this to a file." << std::endl;
myfile.close();
}

Sin

2012-05-31 16:30:09

Oh thanks! I'll start asap!
Also, do you mind linking me to a tutorial where I can create a GUI type thing?

superuser

2012-05-31 16:43:02

From: Shay
Oh thanks! I'll start asap!
Also, do you mind linking me to a tutorial where I can create a GUI type thing?


GUI is more advanced matter in C++. However, I've always fancied wxWidgets.

Frement

2012-05-31 16:48:39

Also check out Qt for GUI and other stuff :)

Sin

2012-05-31 17:10:48

I'll try both of them, thanks!

Sin

2012-06-01 10:14:05

Updated to v1.1 thanks to superuser!