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++ help] Adding a single character to end of string
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
talkerzero
Grandmaster Cheater
Reputation: 1

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Fri Mar 06, 2009 5:27 pm    Post subject: [C++ help] Adding a single character to end of string Reply with quote

Code:
char* shitfuckedup = "string";
shitfuckedup = shitfuckedup + 's';


Why is the value of shitfuckedup simply null? How can I add the 's' to the end of shitfuckedup to make "strings"?
Back to top
View user's profile Send private message Visit poster's website
Spawnfestis
GO Moderator
Reputation: 0

Joined: 02 Nov 2007
Posts: 1746
Location: Pakistan

PostPosted: Fri Mar 06, 2009 5:38 pm    Post subject: Re: [C++ help] Adding a single character to end of string Reply with quote

talker0 wrote:
Code:
char* shitfuckedup = "string";
shitfuckedup = shitfuckedup + 's';


Why is the value of shitfuckedup simply null? How can I add the 's' to the end of shitfuckedup to make "strings"?

Code:
char charVariable = "s";
string stringVariable = "lol";
stringVariable += charVariable;

_________________

CLICK TO HAX MAPLESTORAY ^ !!!!
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Spudgy
Newbie cheater
Reputation: 0

Joined: 13 Jan 2009
Posts: 13

PostPosted: Fri Mar 06, 2009 5:41 pm    Post subject: Reply with quote

strcat(shitfuckedup,"s");
Back to top
View user's profile Send private message
talkerzero
Grandmaster Cheater
Reputation: 1

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Fri Mar 06, 2009 5:51 pm    Post subject: Reply with quote

Let me make it a bit more clear. Smile

I want to add a single character, not an array of characters, to the end of an array. For example, I want to add the character 'a' to the end of the array "aaa", not the array "a" to te end of the array "aaa".

Edit: And, I don't wish to use the string identifier.
Back to top
View user's profile Send private message Visit poster's website
Spudgy
Newbie cheater
Reputation: 0

Joined: 13 Jan 2009
Posts: 13

PostPosted: Fri Mar 06, 2009 5:54 pm    Post subject: Reply with quote

talker0 wrote:
Let me make it a bit more clear. Smile

I want to add a single character, not an array of characters, to the end of an array. For example, I want to add the character 'a' to the end of the array "aaa", not the array "a" to te end of the array "aaa".

Edit: And, I don't wish to use the string identifier.

I already told you, just use strcat.

Eg.
Code:

char* dest = "Hello";
strcat(dest," talker0");
Back to top
View user's profile Send private message
talkerzero
Grandmaster Cheater
Reputation: 1

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Fri Mar 06, 2009 6:52 pm    Post subject: Reply with quote

Added your code to my program. Just closed my window.

Code:
case WM_COMMAND:
         if(wParam == IDC_BUTTON1){
            char buffer[33];
            FilterCharacter("maplestory", 'm', buffer);
            MessageBox(hWnd, buffer, "maplestory without the m", MB_OK);
         }
         break;


Closed the window when I pressed the button assigned the ID IDC_BUTTON1. Sad
Back to top
View user's profile Send private message Visit poster's website
talkerzero
Grandmaster Cheater
Reputation: 1

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Fri Mar 06, 2009 7:41 pm    Post subject: Reply with quote

Thanks smartz, worked fine.

Just one more thing I'd like to ask: What are __out_z, __in_z, and __in? Can't find them on Google..


Last edited by talkerzero on Fri Mar 06, 2009 7:44 pm; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Fri Mar 06, 2009 7:42 pm    Post subject: Reply with quote

talker0 wrote:
Thanks smartz, worked fine.

Just one more thing I'd like to ask: What are __out_z, __in_z, and __in? Can't find them on Google..


__out and __in tell the compiler which way the parameters are coming through..input or output.

The _z tells the compiler that the param is NULL terminated.


**edit:

There is also __in_opt for optional parameters.
Back to top
View user's profile Send private message
talkerzero
Grandmaster Cheater
Reputation: 1

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Fri Mar 06, 2009 7:46 pm    Post subject: Reply with quote

So if you use void funcName(__out_z int a), you can't read from the variable a inside the function? Am I understanding you correctly?
Back to top
View user's profile Send private message Visit poster's website
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Fri Mar 06, 2009 7:51 pm    Post subject: Reply with quote

talker0 wrote:
So if you use void funcName(__out_z int a), you can't read from the variable a inside the function? Am I understanding you correctly?


You would only use the _z on a string or character buffer really..

but, using __out, would require a pointer to the variable type.
Back to top
View user's profile Send private message
talkerzero
Grandmaster Cheater
Reputation: 1

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Fri Mar 06, 2009 8:34 pm    Post subject: Reply with quote

I see.. thanks, smartz, Irwin, everyone. Smile
Back to top
View user's profile Send private message Visit poster's website
nog_lorp
Grandmaster Cheater
Reputation: 0

Joined: 26 Feb 2006
Posts: 743

PostPosted: Fri Mar 06, 2009 8:47 pm    Post subject: Reply with quote

Actually, when they are compiled normally, __out and __in and the like are defined to nothing. They are only used for static analysis tools. They also have the nice effect of communicating to the programmer how the variables are used.
_________________
Mutilated lips give a kiss on the wrist of the worm-like tips of tentacles expanding in my mind
I'm fine accepting only fresh brine you can get another drop of this yeah you wish
Back to top
View user's profile Send private message
talkerzero
Grandmaster Cheater
Reputation: 1

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Fri Mar 06, 2009 8:53 pm    Post subject: Reply with quote

@nog_lorp: Wait, then how come in the function posted by Irwin, using _out had a different effect than not using it?

Do you mean to tell me that these two codes will produce the same result?
Code:
void WriteLetterA(__out_z char buffer){
   buffer = 'a';
}

Code:
void WriteLetterA(char buffer){
   buffer = 'a';
}
Back to top
View user's profile Send private message Visit poster's website
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Fri Mar 06, 2009 9:34 pm    Post subject: Reply with quote

talker0 wrote:
@nog_lorp: Wait, then how come in the function posted by Irwin, using _out had a different effect than not using it?

Do you mean to tell me that these two codes will produce the same result?
Code:
void WriteLetterA(__out_z char buffer){
   buffer = 'a';
}

Code:
void WriteLetterA(char buffer){
   buffer = 'a';
}


Neither of those will work. You need a pointer to the buffer.
Back to top
View user's profile Send private message
Overload
Master Cheater
Reputation: 0

Joined: 08 Feb 2008
Posts: 293

PostPosted: Sat Mar 07, 2009 1:26 am    Post subject: Reply with quote

talker0 wrote:
Thanks smartz, worked fine.

Just one more thing I'd like to ask: What are __out_z, __in_z, and __in? Can't find them on Google..


They are apart of Microsofts standard source code annotation language (SAL language). They provide a set of annotations to describe how a function may use the parameters.

_________________
Blog

Quote:
Rhys says:
you can be my maid
Rhys says:
ill buy you a french maid outfit
Tyler says:
Sounds good
Rhys says:
ill hold you to that
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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