View previous topic :: View next topic |
Author |
Message |
InternetIsSeriousBusiness Grandmaster Cheater Supreme
Reputation: 8
Joined: 12 Jul 2010 Posts: 1268
|
Posted: Mon Jul 30, 2012 1:45 pm Post subject: |
|
|
Ask cryoma. He is the master of all things.
|
|
Back to top |
|
 |
Cryoma Member of the Year
Reputation: 198
Joined: 14 Jan 2009 Posts: 1819
|
Posted: Mon Jul 30, 2012 1:46 pm Post subject: |
|
|
hire gainax, they always delete the last character
|
|
Back to top |
|
 |
gogodr I post too much
Reputation: 125
Joined: 19 Dec 2006 Posts: 2041
|
Posted: Mon Jul 30, 2012 1:48 pm Post subject: |
|
|
its an array...
delete the last element of the array and then resize it
|
|
Back to top |
|
 |
Aniblaze Grandmaster Cheater Supreme
Reputation: 138
Joined: 23 Apr 2006 Posts: 1757 Location: The Netherlands
|
Posted: Mon Jul 30, 2012 1:50 pm Post subject: |
|
|
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 |
|
 |
Cryoma Member of the Year
Reputation: 198
Joined: 14 Jan 2009 Posts: 1819
|
Posted: Mon Jul 30, 2012 1:50 pm Post subject: |
|
|
I'm not familiar but wouldn't you just change
to
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 |
|
 |
Simon :v Grandmaster Cheater
Reputation: 38
Joined: 11 Oct 2006 Posts: 708
|
Posted: Mon Jul 30, 2012 1:54 pm Post subject: |
|
|
Not too gr8 w/ c++ but would the method String.Trim work?
|
|
Back to top |
|
 |
gogodr I post too much
Reputation: 125
Joined: 19 Dec 2006 Posts: 2041
|
Posted: Mon Jul 30, 2012 2:46 pm Post subject: |
|
|
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 |
|
 |
Aniblaze Grandmaster Cheater Supreme
Reputation: 138
Joined: 23 Apr 2006 Posts: 1757 Location: The Netherlands
|
Posted: Mon Jul 30, 2012 3:18 pm Post subject: |
|
|
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 |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Mon Jul 30, 2012 5:24 pm Post subject: |
|
|
Every solution offered so far has tried to give a C solution to a C++ problem. Uhhhhhh
|
|
Back to top |
|
 |
bfsdbsdfbdsfb Grandmaster Cheater
Reputation: 54
Joined: 06 Sep 2007 Posts: 702 Location: Oh noez.
|
Posted: Mon Jul 30, 2012 5:48 pm Post subject: |
|
|
What would the difference be between a string and a char array?
_________________
bsdfbdsfb |
|
Back to top |
|
 |
Fafaffy Cheater
Reputation: 65
Joined: 12 Dec 2007 Posts: 28
|
Posted: Mon Jul 30, 2012 5:51 pm Post subject: |
|
|
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 |
|
 |
bfsdbsdfbdsfb Grandmaster Cheater
Reputation: 54
Joined: 06 Sep 2007 Posts: 702 Location: Oh noez.
|
Posted: Mon Jul 30, 2012 5:54 pm Post subject: |
|
|
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 |
|
 |
Fafaffy Cheater
Reputation: 65
Joined: 12 Dec 2007 Posts: 28
|
Posted: Mon Jul 30, 2012 5:55 pm Post subject: |
|
|
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 |
|
 |
bfsdbsdfbdsfb Grandmaster Cheater
Reputation: 54
Joined: 06 Sep 2007 Posts: 702 Location: Oh noez.
|
Posted: Mon Jul 30, 2012 6:40 pm Post subject: |
|
|
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 |
|
 |
Fafaffy Cheater
Reputation: 65
Joined: 12 Dec 2007 Posts: 28
|
Posted: Mon Jul 30, 2012 6:51 pm Post subject: |
|
|
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 |
|
 |
|