 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
gogodr I post too much
Reputation: 125
Joined: 19 Dec 2006 Posts: 2041
|
Posted: Mon Jul 30, 2012 6:53 pm Post subject: |
|
|
blablfy. wrote: | 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) |
I really doubt a char is 1byte |
|
Back to top |
|
 |
Fafaffy Cheater
Reputation: 65
Joined: 12 Dec 2007 Posts: 28
|
Posted: Mon Jul 30, 2012 6:54 pm Post subject: |
|
|
gogodr wrote: | blablfy. wrote: | 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) |
I really doubt a char is 1byte |
http://uk.answers.yahoo.com/question/index?qid=20081102023710AAZC6N3 |
|
Back to top |
|
 |
gogodr I post too much
Reputation: 125
Joined: 19 Dec 2006 Posts: 2041
|
Posted: Mon Jul 30, 2012 6:57 pm Post subject: |
|
|
oh wait
yeah you might be right, I was thinking in bits |
|
Back to top |
|
 |
bfsdbsdfbdsfb Grandmaster Cheater
Reputation: 54
Joined: 06 Sep 2007 Posts: 702 Location: Oh noez.
|
Posted: Mon Jul 30, 2012 7:08 pm Post subject: |
|
|
blablfy. wrote: | gogodr wrote: | blablfy. wrote: | 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) |
I really doubt a char is 1byte |
http://uk.answers.yahoo.com/question/index?qid=20081102023710AAZC6N3 |
1bit = 0 or 1
2bits = 0, 1, 2 or 3
3 bits = 0, 1, 2, 3, 4, 5
so on so forth right?
So with 8 bits being 1 byte there would be stuff you couldn't store in char? _________________
bsdfbdsfb |
|
Back to top |
|
 |
Fafaffy Cheater
Reputation: 65
Joined: 12 Dec 2007 Posts: 28
|
Posted: Mon Jul 30, 2012 7:15 pm Post subject: |
|
|
akaecius wrote: | blablfy. wrote: | gogodr wrote: | blablfy. wrote: | 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) |
I really doubt a char is 1byte |
http://uk.answers.yahoo.com/question/index?qid=20081102023710AAZC6N3 |
1bit = 0 or 1
2bits = 0, 1, 2 or 3
3 bits = 0, 1, 2, 3, 4, 5
so on so forth right?
So with 8 bits being 1 byte there would be stuff you couldn't store in char? |
1 byte = 256 combinations
1 bit = 0 or 1
2 bits = 00, 01, 11, 10
etc... |
|
Back to top |
|
 |
gogodr I post too much
Reputation: 125
Joined: 19 Dec 2006 Posts: 2041
|
Posted: Mon Jul 30, 2012 7:22 pm Post subject: |
|
|
akaecius wrote: | blablfy. wrote: | gogodr wrote: | blablfy. wrote: | 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) |
I really doubt a char is 1byte |
http://uk.answers.yahoo.com/question/index?qid=20081102023710AAZC6N3 |
1bit = 0 or 1
2bits = 0, 1, 2 or 3
3 bits = 0, 1, 2, 3, 4, 5
so on so forth right?
So with 8 bits being 1 byte there would be stuff you couldn't store in char? |
1bit= 01
2bit = 0123
3bit = 01234567
4bit = 0123456789ABCDEF
you get the idea |
|
Back to top |
|
 |
Andyroo Grandmaster Cheater
Reputation: 2
Joined: 04 Jul 2006 Posts: 964
|
Posted: Tue Jul 31, 2012 1:02 am Post subject: |
|
|
lets say you have a char array char temp[10]
then create a new char array, then copy the substr of temp into it.
char temp2[9]
strncpy(temp2, temp, 9);
make sure you use strncpy, or you'll try to copy a big array into a small array and get a compiler error.
if you want to make a dynamic char array, then you want to do
char *temp2 = new char[strlen(temp)];
and copy into that.
edit:
err you could just put a '\0' where the last char is too LOL looks like you solved it. |
|
Back to top |
|
 |
gogodr I post too much
Reputation: 125
Joined: 19 Dec 2006 Posts: 2041
|
Posted: Tue Jul 31, 2012 11:40 am Post subject: |
|
|
putting null at the end of the array doesnt make it smaller though ... |
|
Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Wed Aug 01, 2012 10:03 am Post subject: |
|
|
blablfy. wrote: | 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) |
the size of an int is implementation defined. for more information on what the standard does define, see here
also with regards to size:
Code: | char[] str = "adsf";
char * str = "asdf"; |
both require 5 bytes (4 bytes for characters + 1 byte for null terminator).
almost everything i've seen in this thread so far is wrong |
|
Back to top |
|
 |
gogodr I post too much
Reputation: 125
Joined: 19 Dec 2006 Posts: 2041
|
Posted: Wed Aug 01, 2012 11:42 am Post subject: |
|
|
how is using malloc to reduce the size wrong? |
|
Back to top |
|
 |
Fafaffy Cheater
Reputation: 65
Joined: 12 Dec 2007 Posts: 28
|
Posted: Wed Aug 01, 2012 12:42 pm Post subject: |
|
|
I'm horrible with C++ and stuff, so nothing I say you should trust
What I was trying to imply was:
Instead of having a item id like this:
You could store the item number as an ascii char _________________
Brillia wrote: | I FUCKING FUCK SEX |
|
|
Back to top |
|
 |
Andyroo Grandmaster Cheater
Reputation: 2
Joined: 04 Jul 2006 Posts: 964
|
Posted: Wed Aug 01, 2012 2:21 pm Post subject: |
|
|
gogodr wrote: | putting null at the end of the array doesnt make it smaller though ... |
he was asking how to delete the last character. |
|
Back to top |
|
 |
gogodr I post too much
Reputation: 125
Joined: 19 Dec 2006 Posts: 2041
|
Posted: Wed Aug 01, 2012 2:55 pm Post subject: |
|
|
Andyroo wrote: | gogodr wrote: | putting null at the end of the array doesnt make it smaller though ... |
he was asking how to delete the last character. |
my point is that he is not deleting it, he is replacing it |
|
Back to top |
|
 |
|
|
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
|
|