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++] How can I delete the last character in a char array?
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Random spam
View previous topic :: View next topic  
Author Message
InternetIsSeriousBusiness
Grandmaster Cheater Supreme
Reputation: 8

Joined: 12 Jul 2010
Posts: 1268

PostPosted: Mon Jul 30, 2012 1:45 pm    Post subject: Reply with quote

Ask cryoma. He is the master of all things.
Back to top
View user's profile Send private message
Cryoma
Member of the Year
Reputation: 198

Joined: 14 Jan 2009
Posts: 1819

PostPosted: Mon Jul 30, 2012 1:46 pm    Post subject: Reply with quote

hire gainax, they always delete the last character
Back to top
View user's profile Send private message
gogodr
I post too much
Reputation: 125

Joined: 19 Dec 2006
Posts: 2041

PostPosted: Mon Jul 30, 2012 1:48 pm    Post subject: Reply with quote

its an array...
delete the last element of the array and then resize it
Back to top
View user's profile Send private message MSN Messenger
Aniblaze
Grandmaster Cheater Supreme
Reputation: 138

Joined: 23 Apr 2006
Posts: 1757
Location: The Netherlands

PostPosted: Mon Jul 30, 2012 1:50 pm    Post subject: Reply with quote

Doesn't C++ have a 'substr' function, much like PHP? I would use that, and don't forget to check if the string is empty. You'll be looking at an exception otherwise.
Back to top
View user's profile Send private message
Cryoma
Member of the Year
Reputation: 198

Joined: 14 Jan 2009
Posts: 1819

PostPosted: Mon Jul 30, 2012 1:50 pm    Post subject: Reply with quote

I'm not familiar but wouldn't you just change
Code:
char derp [5];

to
Code:
char derp [4];

and it removes the last one?
Probably not what you were looking for.

Aniblaze wrote:
Doesn't C++ have a 'substr' function, much like PHP? I would use that, and don't forget to check if the string is empty. You'll be looking at an exception otherwise.


String?
wat
Back to top
View user's profile Send private message
Simon :v
Grandmaster Cheater
Reputation: 38

Joined: 11 Oct 2006
Posts: 708

PostPosted: Mon Jul 30, 2012 1:54 pm    Post subject: Reply with quote

Not too gr8 w/ c++ but would the method String.Trim work?
Back to top
View user's profile Send private message MSN Messenger
gogodr
I post too much
Reputation: 125

Joined: 19 Dec 2006
Posts: 2041

PostPosted: Mon Jul 30, 2012 2:46 pm    Post subject: Reply with quote

uhm..
you wont be deleting the last character of the arraywith that but making it null
and strlen doesnt read null characters, sizeof does

I think what you want is to use sizeof and then malloc to resize the array
Back to top
View user's profile Send private message MSN Messenger
Aniblaze
Grandmaster Cheater Supreme
Reputation: 138

Joined: 23 Apr 2006
Posts: 1757
Location: The Netherlands

PostPosted: Mon Jul 30, 2012 3:18 pm    Post subject: Reply with quote

Cryoma wrote:
Aniblaze wrote:
Doesn't C++ have a 'substr' function, much like PHP? I would use that, and don't forget to check if the string is empty. You'll be looking at an exception otherwise.


String?
wat

I was assuming he was talking about a character array.

EDIT: Ah never mind, I said string instead of char, my bad.
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Mon Jul 30, 2012 5:24 pm    Post subject: Reply with quote

Every solution offered so far has tried to give a C solution to a C++ problem. Uhhhhhh
Back to top
View user's profile Send private message
bfsdbsdfbdsfb
Grandmaster Cheater
Reputation: 54

Joined: 06 Sep 2007
Posts: 702
Location: Oh noez.

PostPosted: Mon Jul 30, 2012 5:48 pm    Post subject: Reply with quote

What would the difference be between a string and a char array?
_________________
bsdfbdsfb
Back to top
View user's profile Send private message
Fafaffy
Cheater
Reputation: 65

Joined: 12 Dec 2007
Posts: 28

PostPosted: Mon Jul 30, 2012 5:51 pm    Post subject: Reply with quote

akaecius wrote:
What would the difference be between a string and a char array?

String is like a sentence (Like "Fuck you")

Char array is a series of characters (Like "F", "u", "c", "k", " ", "y", "o", "u")

Char array = wastes less memory
String = more memory
Back to top
View user's profile Send private message Send e-mail
bfsdbsdfbdsfb
Grandmaster Cheater
Reputation: 54

Joined: 06 Sep 2007
Posts: 702
Location: Oh noez.

PostPosted: Mon Jul 30, 2012 5:54 pm    Post subject: Reply with quote

blablfy. wrote:
akaecius wrote:
What would the difference be between a string and a char array?

String is like a sentence (Like "Fuck you")

Char array is a series of characters (Like "F", "u", "c", "k", " ", "y", "o", "u")

Char array = wastes less memory
String = more memory

yeah I know what a string is I was just wondering since "char"(characters obv.), characters would be what a string consisted of; letters, symbols, numbers.

I was just wondering why there was a difference like that.

_________________
bsdfbdsfb
Back to top
View user's profile Send private message
Fafaffy
Cheater
Reputation: 65

Joined: 12 Dec 2007
Posts: 28

PostPosted: Mon Jul 30, 2012 5:55 pm    Post subject: Reply with quote

akaecius wrote:
blablfy. wrote:
akaecius wrote:
What would the difference be between a string and a char array?

String is like a sentence (Like "Fuck you")

Char array is a series of characters (Like "F", "u", "c", "k", " ", "y", "o", "u")

Char array = wastes less memory
String = more memory

yeah I know what a string is I was just wondering since "char"(characters obv.), characters would be what a string consisted of; letters, symbols, numbers.

I was just wondering why there was a difference like that.

A char can be anything, a symbol/letter/etc... The only real reason I see it's good for is saving very small amount of data (Like saving an item on a game, and the item has a number id which is converted to a char), or memory management.
Back to top
View user's profile Send private message Send e-mail
bfsdbsdfbdsfb
Grandmaster Cheater
Reputation: 54

Joined: 06 Sep 2007
Posts: 702
Location: Oh noez.

PostPosted: Mon Jul 30, 2012 6:40 pm    Post subject: Reply with quote

blablfy. wrote:
akaecius wrote:
blablfy. wrote:
akaecius wrote:
What would the difference be between a string and a char array?

String is like a sentence (Like "Fuck you")

Char array is a series of characters (Like "F", "u", "c", "k", " ", "y", "o", "u")

Char array = wastes less memory
String = more memory

yeah I know what a string is I was just wondering since "char"(characters obv.), characters would be what a string consisted of; letters, symbols, numbers.

I was just wondering why there was a difference like that.

A char can be anything, a symbol/letter/etc... The only real reason I see it's good for is saving very small amount of data (Like saving an item on a game, and the item has a number id which is converted to a char), or memory management.

If it's just a number ID why not just store it as an integer variable?

_________________
bsdfbdsfb
Back to top
View user's profile Send private message
Fafaffy
Cheater
Reputation: 65

Joined: 12 Dec 2007
Posts: 28

PostPosted: Mon Jul 30, 2012 6:51 pm    Post subject: Reply with quote

akaecius wrote:
blablfy. wrote:
akaecius wrote:
blablfy. wrote:
akaecius wrote:
What would the difference be between a string and a char array?

String is like a sentence (Like "Fuck you")

Char array is a series of characters (Like "F", "u", "c", "k", " ", "y", "o", "u")

Char array = wastes less memory
String = more memory

yeah I know what a string is I was just wondering since "char"(characters obv.), characters would be what a string consisted of; letters, symbols, numbers.

I was just wondering why there was a difference like that.

A char can be anything, a symbol/letter/etc... The only real reason I see it's good for is saving very small amount of data (Like saving an item on a game, and the item has a number id which is converted to a char), or memory management.

If it's just a number ID why not just store it as an integer variable?

Memory management. char = 1 byte, int = 4 bytes (or something like that)
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Random spam All times are GMT - 6 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
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