Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


C++ iostream sprintf_s

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Fri Oct 03, 2008 8:46 am    Post subject: C++ iostream sprintf_s Reply with quote

so im no good at C++, and was just wondering, is it possible to use just one function(like sprintf or sprintf_s) without including the whole iostream

im making a dll, and including iostream makes it go from 9 kb to 450kb, for a mere 3 uses of sprintf_s

is this at all possible?

_________________
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Fri Oct 03, 2008 8:51 am    Post subject: Reply with quote

Not sure in the case of C++ but in MASM when I had to do something similar, instead of including the entire library, I just copied the code and put it as a prototype function embedded in the app and called it from that.

Not sure if you are able to get the 'source' for that function though since I don't really code C++ yet.
Back to top
View user's profile Send private message
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Fri Oct 03, 2008 8:55 am    Post subject: Reply with quote

i get what your saying, though i dont know how id go about get the source for it, very iffy

i can see why masm would be easier to do that sort of thing in, since you get right down to ASM, which could be done in C++, though with more difficulty

_________________
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Fri Oct 03, 2008 10:12 am    Post subject: Reply with quote

If you're linking the runtime library statically, do it dynamically.
Back to top
View user's profile Send private message
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Fri Oct 03, 2008 10:30 am    Post subject: Reply with quote

well i might not even need that actually, all im trying to do is this:

Code:
static long counter = 0
DWORD cWritten
HANDLE stdOut
CHAR outputstr[7]

stdOut = GetStdHandle(STD_OUTPUT_HANDLE)
sprintf_s(outputstr, 6, "Hello", ++counter, __LINE__)
WriteFile(stdout, outputstr, (int)strlen(outputstr), &cWritten, NULL)


i basically just need to put text on a console i've made using AllocConsole

p.s. if you could tell me how to clear the console, that would help too

_________________
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Fri Oct 03, 2008 12:57 pm    Post subject: Reply with quote

GetStdHandle, GetConsoleScreenBufferInfo and FillConsoleOutputCharacter.
Back to top
View user's profile Send private message
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Fri Oct 03, 2008 9:41 pm    Post subject: Reply with quote

SOmething like this?:

Code:

DWORD outputhandle;
STRING mystring;
DWORD charwritten;
INT i;
COORD spot;

mystring = "Is this going to work?"
spot.X = 5;
spot.Y = 6;
outputhandle = GetStdHandle(STD_OUTPUT_HANDLE);

for(int i=0; i<strlen(mystring);i++)
{
FillConsoleOutputCharacter(outputhandle, mystring[i], 1, spot, &charwritten)
spot.X = spot.X + 1;
}


i just whipped that up then, anywhere close to being right?

Edit: got it to work:


Code:
HANDLE outputhandle;
DWORD charwritten;
INT i;
COORD spot;

char mystring [] = "Hello";
spot.X = 5;
spot.Y = 6;
outputhandle = GetStdHandle(STD_OUTPUT_HANDLE);

for(int i=0; i<strlen(mystring);i++)
{
FillConsoleOutputCharacterA(outputhandle, mystring[i], 1, spot, &charwritten);
spot.X = spot.X + 1;
}

_________________
Back to top
View user's profile Send private message
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Sat Oct 04, 2008 4:12 pm    Post subject: Reply with quote

exactly thats why I recommend never use C++ wrappers, C++ fucked up C is much better but it doesn't mean you can't use C++'s new command other stuff like class'es then that.. all other shit is garbage.
Plus most big companies know this.. they code most popular games in C instead of C++ take for example Quake 4 coded completely in C.

you can tell that it's a C++ wrapper then it has no [b].h file[/h] at the end

instead of #include<iostream> I would use stdio which has sprintf() what is sprintf_s() anyways some copycat of sprintf()? your just bloating your project to do the same basic shit..
like fstream file opening.. would be the same as stdio's fopen() and it would be much faster.. and the size of your file would be like 20 KB instead of 80 KB..

anyways just try to get things done without those headers with no .h at end and it will be all good.. like the string class #include <string> its so useless you could just use char* name and keep size in a int and same results.. and 50KB less in file size.

_________________
Hacks I made for kongregate.
Kongregate Universal Badge Hack: http://forum.cheatengine.org/viewtopic.php?p=4129411
Kongreate Auto Rating/Voter hack: http://forum.cheatengine.org/viewtopic.php?t=263576
Took a test lol
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Sat Oct 04, 2008 4:59 pm    Post subject: Reply with quote

pkedpker wrote:
Plus most big companies know this.. they code most popular games in C instead of C++ take for example Quake 4 coded completely in C.


Uh, this is completely false.

Quake 3 was the last engine written in C. In fact, all of the engines up to Quake 3 are open source now.

Most modern engines are likely written entirely in C++/ASM for the speedy bits.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites