C
CBFalconer
Harald said:Does it display better like this?
Yes, except for the middle character in the name "D?k". That is
still a bind for any return e-mail addresses.
Harald said:Does it display better like this?
Harald van Dijk said:Does it display better like this?
what is the difference between a single character and a string
consisting only one character
Try this program:
#include <stdio.h>
int main(void) {
char c0 = '0';
char c1[] = "0";
printf("Size of c0 is %u\nSize of c1 is %u\n", sizeof c0, sizeof c1);
return 0;
}
snip
strlen() and common sense say otherwise. You are confusing how big
something is with how much space it takes to store it. They are rarely
the same thing, and the later is usually greater than the former.
Harald said:Does it display better like this?
Barry Schwarz said:On Sat, 24 Nov 2007 15:56:07 +0000 (UTC),
And you are refusing to accept the definition in the standard. From
para 7.1.1-1: "A string is a contiguous sequence of characters
terminated by and including the first null character."
santosh said:Oops. It was correct when I received and replied to it, but not when I
read it back, as you can see.
Richard said:And you are refusing to understand what KM said. There is a difference
between the length of a string and the space needed to store it. As is
clear from this thread and has been true since the day C was invented.
Length is analogous to "how many character do you display in the real
world" whereas "size" is "how much storage space do you need".
J. J. Farrell said:And you are refusing to look at what Kenny said in context. Kenny
claimed that the statement
was wrong. Kenny was incorrect, totally and absolutely, by
definition. Kenny introduced the ideas of "how big something is" and
"how much space it takes" which aren't relevant to the statement he
was supposedly correcting. A string consists of a sequence of
characters up to and including the first null character, and has done
since the day C was invented.
If that's how you choose to define them, that's fine. It's not
relevant to the question in hand though.
Richard said:Not in the context of what he said which was that "strlen" and "common
sense" say otherwise. Not the standard.
strlen and "common sense" say that the string length of "0" is 1. The
size is 2. That is a different thing.
But we know what me mean. No point in getting in tedious language wars
here.
Agreed.
Actually its totally relevant since it defines the difference between
the "length" and the "size" which were the pertinent points here.
santosh said:Yes. It is now displayed correctly.
Here too.
Richard said:And you are refusing to understand what KM said. There is a difference
between the length of a string and the space needed to store it. As is
clear from this thread and has been true since the day C was invented.
Length is analogous to "how many character do you display in the real
world" whereas "size" is "how much storage space do you need".
And you are refusing to understand what KM said. There is a difference
between the length of a string and the space needed to store it. As is
clear from this thread and has been true since the day C was invented.
Length is analogous to "how many character do you display in the real
world" whereas "size" is "how much storage space do you need".
The nul terminator isn't one of the characters "in" a string.
pete said:That's just completely wrong.
The standard says that the null byte is part of the string.
The number of participants in this thread
who know what a string is, is dissappointingly small.
char str[] = "Hello";pete said:That's just completely wrong.
The standard says that the null byte is part of the string.
The number of participants in this thread
who know what a string is, is dissappointingly small.
char str[] = "Hello";
The sizeof str is 6 while strlen(str) is 5.
While the nul is of type char it's not really a character, is it?
Chris said:The blindingly obvious [1]
meaning of "the string S contains the character C" and the meaning
implied by the Standard are not the same;
pete said:Chris said:The blindingly obvious [1]
meaning of "the string S contains the character C" and the meaning
implied by the Standard are not the same;
I prefer to use the C standard's definitions
for terms when discussing C in the C newsgroup.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.