473,385 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

what's the difference between the next 2 declarations?

Hi,

What's the difference between:

char *x="abcde";

and

char y[]={"abcde"};
I can't modify the value of the variable x in functions, but y can be do.

Is there any other similar problem need to be notice?

Thanks in advance!

Wade Yin
Nov 14 '05 #1
48 2599
On Mon, 5 Apr 2004 13:05:38 +0800, "Wade Yin" <li********@163.com>
wrote in comp.lang.c:
Hi,

What's the difference between:

char *x="abcde";
x is a pointer to the a six character (including the '\0') string
literal. Attempting to modify a string literal causes undefined
behavior. x itself can be modified to point to a different array of
characters.
and

char y[]={"abcde"};
y is an array of 6 characters, initialized with the string literal.
The characters in y can be changed.
I can't modify the value of the variable x in functions, but y can be do.

Is there any other similar problem need to be notice?
No, the situation with string literals is a special case and there are
no others like it, except for wide string literals.
Thanks in advance!

Wade Yin


--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 14 '05 #2
On Mon, 5 Apr 2004 13:05:38 +0800, "Wade Yin" <li********@163.com>
wrote in comp.lang.c:
Hi,

What's the difference between:

char *x="abcde";
x is a pointer to the a six character (including the '\0') string
literal. Attempting to modify a string literal causes undefined
behavior. x itself can be modified to point to a different array of
characters.
and

char y[]={"abcde"};
y is an array of 6 characters, initialized with the string literal.
The characters in y can be changed.
I can't modify the value of the variable x in functions, but y can be do.

Is there any other similar problem need to be notice?
No, the situation with string literals is a special case and there are
no others like it, except for wide string literals.
Thanks in advance!

Wade Yin


--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 14 '05 #3

"Jack Klein" <ja*******@spamcop.net>
??????:1l********************************@4ax.com. ..
On Mon, 5 Apr 2004 13:05:38 +0800, "Wade Yin" <li********@163.com>
wrote in comp.lang.c:
Hi,

What's the difference between:

char *x="abcde";
x is a pointer to the a six character (including the '\0') string
literal. Attempting to modify a string literal causes undefined
behavior. x itself can be modified to point to a different array of
characters.


How does "abcde" stored in memory? we can find x in memory, but we can't
operate it?

and

char y[]={"abcde"};


y is an array of 6 characters, initialized with the string literal.
The characters in y can be changed.
I can't modify the value of the variable x in functions, but y can be do.
Is there any other similar problem need to be notice?


No, the situation with string literals is a special case and there are
no others like it, except for wide string literals.
Thanks in advance!

Wade Yin


--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html

Nov 14 '05 #4

"Jack Klein" <ja*******@spamcop.net>
??????:1l********************************@4ax.com. ..
On Mon, 5 Apr 2004 13:05:38 +0800, "Wade Yin" <li********@163.com>
wrote in comp.lang.c:
Hi,

What's the difference between:

char *x="abcde";
x is a pointer to the a six character (including the '\0') string
literal. Attempting to modify a string literal causes undefined
behavior. x itself can be modified to point to a different array of
characters.


How does "abcde" stored in memory? we can find x in memory, but we can't
operate it?

and

char y[]={"abcde"};


y is an array of 6 characters, initialized with the string literal.
The characters in y can be changed.
I can't modify the value of the variable x in functions, but y can be do.
Is there any other similar problem need to be notice?


No, the situation with string literals is a special case and there are
no others like it, except for wide string literals.
Thanks in advance!

Wade Yin


--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html

Nov 14 '05 #5
Wade Yin wrote:
char *x="abcde";


x is a pointer to the a six character (including the '\0') string
literal. Attempting to modify a string literal causes undefined
behavior. x itself can be modified to point to a different array of
characters.

How does "abcde" stored in memory? we can find x in memory, but we can't
operate it?


Can't "change it", yes, the standard says that you cannot change a
string literal. The implementation has the freedom to place it in a
write-only protected memory segment, in ROM, or in fact anywhere it
desires. It may even put it exactly where it puts a modifiable character
array.

--
John Tsiombikas (Nuclear / the Lab)
nu*****@siggraph.org
http://thelab.demoscene.gr/nuclear/
Nov 14 '05 #6
Wade Yin wrote:
char *x="abcde";


x is a pointer to the a six character (including the '\0') string
literal. Attempting to modify a string literal causes undefined
behavior. x itself can be modified to point to a different array of
characters.

How does "abcde" stored in memory? we can find x in memory, but we can't
operate it?


Can't "change it", yes, the standard says that you cannot change a
string literal. The implementation has the freedom to place it in a
write-only protected memory segment, in ROM, or in fact anywhere it
desires. It may even put it exactly where it puts a modifiable character
array.

--
John Tsiombikas (Nuclear / the Lab)
nu*****@siggraph.org
http://thelab.demoscene.gr/nuclear/
Nov 14 '05 #7
Wade Yin <li********@163.com> spoke thus:
How does "abcde" stored in memory?
Exactly how is (I believe) up to the implementation, but commonly it
ends up in read-only memory.
we can find x in memory, but we can't operate it?


Not without bad things potentially happening - depending on the
implementation, attempting to access memory denoted as read-only can
cause your program to crash.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 14 '05 #8
Wade Yin <li********@163.com> spoke thus:
How does "abcde" stored in memory?
Exactly how is (I believe) up to the implementation, but commonly it
ends up in read-only memory.
we can find x in memory, but we can't operate it?


Not without bad things potentially happening - depending on the
implementation, attempting to access memory denoted as read-only can
cause your program to crash.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 14 '05 #9
On Mon, 5 Apr 2004 13:36:27 +0800, "Wade Yin" <li********@163.com> wrote:

"Jack Klein" <ja*******@spamcop.net>
??????:1l********************************@4ax.com ...
On Mon, 5 Apr 2004 13:05:38 +0800, "Wade Yin" <li********@163.com>
wrote in comp.lang.c:
> Hi,
>
> What's the difference between:
>
> char *x="abcde";


x is a pointer to the a six character (including the '\0') string
literal. Attempting to modify a string literal causes undefined
behavior. x itself can be modified to point to a different array of
characters.


How does "abcde" stored in memory? we can find x in memory, but we can't
operate it?

If you go to this page:
http://www.bdsoft.com/courses/cprog-details.html
and click on the "slides" link, slides #33-42 illustrate the different ways
in which your two constructs are stored in memory, and the sorts of things
you're permitted to do with them.

(Note to rest of group: I haven't updated this material since I began
hanging out in clc, so there are probably lots of nits to pick WRT saying
what's const and what's not, etc. Rest assured I'll go over the entire
/course/ before I ever actually teach it again....)
-leor

--
Leor Zolman --- BD Software --- www.bdsoft.com
On-Site Training in C/C++, Java, Perl and Unix
C++ users: Download BD Software's free STL Error Message Decryptor at:
www.bdsoft.com/tools/stlfilt.html
Nov 14 '05 #10
On Mon, 5 Apr 2004 13:36:27 +0800, "Wade Yin" <li********@163.com> wrote:

"Jack Klein" <ja*******@spamcop.net>
??????:1l********************************@4ax.com ...
On Mon, 5 Apr 2004 13:05:38 +0800, "Wade Yin" <li********@163.com>
wrote in comp.lang.c:
> Hi,
>
> What's the difference between:
>
> char *x="abcde";


x is a pointer to the a six character (including the '\0') string
literal. Attempting to modify a string literal causes undefined
behavior. x itself can be modified to point to a different array of
characters.


How does "abcde" stored in memory? we can find x in memory, but we can't
operate it?

If you go to this page:
http://www.bdsoft.com/courses/cprog-details.html
and click on the "slides" link, slides #33-42 illustrate the different ways
in which your two constructs are stored in memory, and the sorts of things
you're permitted to do with them.

(Note to rest of group: I haven't updated this material since I began
hanging out in clc, so there are probably lots of nits to pick WRT saying
what's const and what's not, etc. Rest assured I'll go over the entire
/course/ before I ever actually teach it again....)
-leor

--
Leor Zolman --- BD Software --- www.bdsoft.com
On-Site Training in C/C++, Java, Perl and Unix
C++ users: Download BD Software's free STL Error Message Decryptor at:
www.bdsoft.com/tools/stlfilt.html
Nov 14 '05 #11
In <c4**********@mail.cn99.com> "Wade Yin" <li********@163.com> writes:
What's the difference between:

char *x="abcde";

and

char y[]={"abcde"};


How about reading the FAQ *before* posting?

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #12
In <c4**********@mail.cn99.com> "Wade Yin" <li********@163.com> writes:
What's the difference between:

char *x="abcde";

and

char y[]={"abcde"};


How about reading the FAQ *before* posting?

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #13
In <c4**********@chessie.cirr.com> Christopher Benson-Manica <at***@nospam.cyberspace.org> writes:
Wade Yin <li********@163.com> spoke thus:
How does "abcde" stored in memory?


Exactly how is (I believe) up to the implementation, but commonly it
ends up in read-only memory.


It's less common than you might think. Read-only string literals are a
C89 invention and many implementors have chosen compatibility with
pre-ANSI C programs. In pre-ANSI C, string literals were writable and
the compiler was not free to merge multiple identical string literals.
Some compilers (e.g. gcc) even let the user choose between the two
flavours of string literals:

-fwritable-strings
Store string constants in the writable data segment and don't
uniquize them. This is for compatibility with old programs
which assume they can write into string constants.
we can find x in memory, but we can't operate it?


Not without bad things potentially happening - depending on the
implementation, attempting to access memory denoted as read-only can
cause your program to crash.


Well I can't find anything wrong with read-only accesses to read-only
memory...

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #14
In <c4**********@chessie.cirr.com> Christopher Benson-Manica <at***@nospam.cyberspace.org> writes:
Wade Yin <li********@163.com> spoke thus:
How does "abcde" stored in memory?


Exactly how is (I believe) up to the implementation, but commonly it
ends up in read-only memory.


It's less common than you might think. Read-only string literals are a
C89 invention and many implementors have chosen compatibility with
pre-ANSI C programs. In pre-ANSI C, string literals were writable and
the compiler was not free to merge multiple identical string literals.
Some compilers (e.g. gcc) even let the user choose between the two
flavours of string literals:

-fwritable-strings
Store string constants in the writable data segment and don't
uniquize them. This is for compatibility with old programs
which assume they can write into string constants.
we can find x in memory, but we can't operate it?


Not without bad things potentially happening - depending on the
implementation, attempting to access memory denoted as read-only can
cause your program to crash.


Well I can't find anything wrong with read-only accesses to read-only
memory...

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #15
On 5 Apr 2004 15:31:17 GMT, Da*****@cern.ch (Dan Pop) wrote in
comp.lang.c:
In <c4**********@chessie.cirr.com> Christopher Benson-Manica <at***@nospam.cyberspace.org> writes:
Wade Yin <li********@163.com> spoke thus:
How does "abcde" stored in memory?


Exactly how is (I believe) up to the implementation, but commonly it
ends up in read-only memory.


It's less common than you might think.


....in desk top and workstation type implementations. It is very
common in embedded implementation, so much so in fact that I would
seriously consider rejecting a compiler that copied string literals
from read-only storage to RAM by default.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 14 '05 #16
On 5 Apr 2004 15:31:17 GMT, Da*****@cern.ch (Dan Pop) wrote in
comp.lang.c:
In <c4**********@chessie.cirr.com> Christopher Benson-Manica <at***@nospam.cyberspace.org> writes:
Wade Yin <li********@163.com> spoke thus:
How does "abcde" stored in memory?


Exactly how is (I believe) up to the implementation, but commonly it
ends up in read-only memory.


It's less common than you might think.


....in desk top and workstation type implementations. It is very
common in embedded implementation, so much so in fact that I would
seriously consider rejecting a compiler that copied string literals
from read-only storage to RAM by default.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 14 '05 #17
In <61********************************@4ax.com> Jack Klein <ja*******@spamcop.net> writes:
On 5 Apr 2004 15:31:17 GMT, Da*****@cern.ch (Dan Pop) wrote in
comp.lang.c:
In <c4**********@chessie.cirr.com> Christopher Benson-Manica <at***@nospam.cyberspace.org> writes:
>Wade Yin <li********@163.com> spoke thus:
>
>> How does "abcde" stored in memory?
>
>Exactly how is (I believe) up to the implementation, but commonly it
>ends up in read-only memory.


It's less common than you might think.


...in desk top and workstation type implementations.


I.e. in what the standard calls hosted implementations, which happen to
be the default implementations for this newsgroup.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #18
In <61********************************@4ax.com> Jack Klein <ja*******@spamcop.net> writes:
On 5 Apr 2004 15:31:17 GMT, Da*****@cern.ch (Dan Pop) wrote in
comp.lang.c:
In <c4**********@chessie.cirr.com> Christopher Benson-Manica <at***@nospam.cyberspace.org> writes:
>Wade Yin <li********@163.com> spoke thus:
>
>> How does "abcde" stored in memory?
>
>Exactly how is (I believe) up to the implementation, but commonly it
>ends up in read-only memory.


It's less common than you might think.


...in desk top and workstation type implementations.


I.e. in what the standard calls hosted implementations, which happen to
be the default implementations for this newsgroup.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #19
Dan Pop wrote:
Wade Yin writes:
What's the difference between:

char *x="abcde";

and

char y[]={"abcde"};


How about reading the FAQ *before* posting?


Why would Wade read the [C] FAQ *before* posting?
Does the FAQ answer this question?
Can you cite and quote the relevant FAQ?

Nov 14 '05 #20
Dan Pop wrote:
Wade Yin writes:
What's the difference between:

char *x="abcde";

and

char y[]={"abcde"};


How about reading the FAQ *before* posting?


Why would Wade read the [C] FAQ *before* posting?
Does the FAQ answer this question?
Can you cite and quote the relevant FAQ?

Nov 14 '05 #21

"E. Robert Tisdale" <E.**************@jpl.nasa.gov> a écrit dans le message
de news:40**************@jpl.nasa.gov...

Hi,
Does the FAQ answer this question?
Yes.
Can you cite and quote the relevant FAQ?


The 1.32 FAQ answers to the Wade's question.
http://www.eskimo.com/~scs/C-faq/q1.32.html

Regis
Nov 14 '05 #22

"E. Robert Tisdale" <E.**************@jpl.nasa.gov> a écrit dans le message
de news:40**************@jpl.nasa.gov...

Hi,
Does the FAQ answer this question?
Yes.
Can you cite and quote the relevant FAQ?


The 1.32 FAQ answers to the Wade's question.
http://www.eskimo.com/~scs/C-faq/q1.32.html

Regis
Nov 14 '05 #23
On 5 Apr 2004 14:33:03 GMT, Da*****@cern.ch (Dan Pop) wrote:

How about reading the FAQ *before* posting?
Sure, most of things can be deal with by FAQ,

But It's too long to fit for a single question, Right?!

Dan


Nov 14 '05 #24
On 5 Apr 2004 14:33:03 GMT, Da*****@cern.ch (Dan Pop) wrote:

How about reading the FAQ *before* posting?
Sure, most of things can be deal with by FAQ,

But It's too long to fit for a single question, Right?!

Dan


Nov 14 '05 #25
On Tue, 6 Apr 2004 19:14:48 +0200, "Régis Troadec" <re**@wanadoo.fr> wrote:
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> a ?crit dans le message
de news:40**************@jpl.nasa.gov...

Hi,
Does the FAQ answer this question?


Yes.
Can you cite and quote the relevant FAQ?


The 1.32 FAQ answers to the Wade's question.
http://www.eskimo.com/~scs/C-faq/q1.32.html


Cool...

I should read it carefully after this question....

But sometime you can't find it in time, so you have to ask at here..:(

So please keep patient...

Thank you all.

You gave me very good help...

Nov 14 '05 #26
On Tue, 6 Apr 2004 19:14:48 +0200, "Régis Troadec" <re**@wanadoo.fr> wrote:
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> a ?crit dans le message
de news:40**************@jpl.nasa.gov...

Hi,
Does the FAQ answer this question?


Yes.
Can you cite and quote the relevant FAQ?


The 1.32 FAQ answers to the Wade's question.
http://www.eskimo.com/~scs/C-faq/q1.32.html


Cool...

I should read it carefully after this question....

But sometime you can't find it in time, so you have to ask at here..:(

So please keep patient...

Thank you all.

You gave me very good help...

Nov 14 '05 #27
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote:
Dan Pop wrote:
How about reading the FAQ *before* posting?


Why would Wade read the [C] FAQ *before* posting?


Because it is nothing but polite to read the FAQ for _any_ newsgroup you
intend to start posting to. So is reading a reasonable amount of
backlog. It's basic netiquette, really. Which explains why it's done so
rarely :-(

Richard
Nov 14 '05 #28
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote:
Dan Pop wrote:
How about reading the FAQ *before* posting?


Why would Wade read the [C] FAQ *before* posting?


Because it is nothing but polite to read the FAQ for _any_ newsgroup you
intend to start posting to. So is reading a reasonable amount of
backlog. It's basic netiquette, really. Which explains why it's done so
rarely :-(

Richard
Nov 14 '05 #29
The FAQ shows the declaration like:

char a[] = "string literal";

But in the OP's question it is like:

char y[] = {"string literal"};

Are they same?
Nov 14 '05 #30
The FAQ shows the declaration like:

char a[] = "string literal";

But in the OP's question it is like:

char y[] = {"string literal"};

Are they same?
Nov 14 '05 #31
In <ff********************************@4ax.com> Wade Yin <wa*****@tom.com> writes:
On 5 Apr 2004 14:33:03 GMT, Da*****@cern.ch (Dan Pop) wrote:

How about reading the FAQ *before* posting?


Sure, most of things can be deal with by FAQ,

But It's too long to fit for a single question, Right?!


Wrong! The FAQ is divided into sections so that you don't have to
read the parts that are obviously irrelevant to your question. And your
question is the second in the section... Arrays and Pointers, i.e. the
very place where an intelligent person would have searched the answer.

So, you have NO excuse for not doing your homework before posting...

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #32
In <ff********************************@4ax.com> Wade Yin <wa*****@tom.com> writes:
On 5 Apr 2004 14:33:03 GMT, Da*****@cern.ch (Dan Pop) wrote:

How about reading the FAQ *before* posting?


Sure, most of things can be deal with by FAQ,

But It's too long to fit for a single question, Right?!


Wrong! The FAQ is divided into sections so that you don't have to
read the parts that are obviously irrelevant to your question. And your
question is the second in the section... Arrays and Pointers, i.e. the
very place where an intelligent person would have searched the answer.

So, you have NO excuse for not doing your homework before posting...

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #33
In <40**************@jpl.nasa.gov> "E. Robert Tisdale" <E.**************@jpl.nasa.gov> writes:
Dan Pop wrote:
Wade Yin writes:
What's the difference between:

char *x="abcde";

and

char y[]={"abcde"};
How about reading the FAQ *before* posting?


Why would Wade read the [C] FAQ *before* posting?
Does the FAQ answer this question?


Yup. In "graphic" detail.
Can you cite and quote the relevant FAQ?


Yup, but only if you openly admit that you cannot find it yourself.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #34
In <40**************@jpl.nasa.gov> "E. Robert Tisdale" <E.**************@jpl.nasa.gov> writes:
Dan Pop wrote:
Wade Yin writes:
What's the difference between:

char *x="abcde";

and

char y[]={"abcde"};
How about reading the FAQ *before* posting?


Why would Wade read the [C] FAQ *before* posting?
Does the FAQ answer this question?


Yup. In "graphic" detail.
Can you cite and quote the relevant FAQ?


Yup, but only if you openly admit that you cannot find it yourself.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #35
In <f7*************************@posting.google.com> iu*********@yahoo.co.in (anonymous) writes:
The FAQ shows the declaration like:

char a[] = "string literal";

But in the OP's question it is like:

char y[] = {"string literal"};

Are they same?


Why would they be any different? What difference do you expect those
superfluous braces to make?

FYI:

int i = {1};

is also allowed. I hope you're not going to ask me if it's the same as

int i = 1;

;-)

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #36
In <f7*************************@posting.google.com> iu*********@yahoo.co.in (anonymous) writes:
The FAQ shows the declaration like:

char a[] = "string literal";

But in the OP's question it is like:

char y[] = {"string literal"};

Are they same?


Why would they be any different? What difference do you expect those
superfluous braces to make?

FYI:

int i = {1};

is also allowed. I hope you're not going to ask me if it's the same as

int i = 1;

;-)

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #37
Richard Bos wrote:
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote:
Dan Pop wrote:
How about reading the FAQ *before* posting?


Why would Wade read the [C] FAQ *before* posting?


Because it is nothing but polite to read the FAQ for _any_
newsgroup you intend to start posting to. So is reading a
reasonable amount of backlog. It's basic netiquette, really.
Which explains why it's done so rarely :-(

+-------------------+ .:\:\:/:/:.
| PLEASE DO NOT | :.:\:\:/:/:.:
| FEED THE TROLLS | :=.' - - '.=:
| | '=(\ 9 9 /)='
| Thank you, | ( (_) )
| Management | /`-vvv-'\
+-------------------+ / \
| | @@@ / /|,,,,,|\ \
| | @@@ /_// /^\ \\_\
@x@@x@ | | |/ WW( ( ) )WW
\||||/ | | \| __\,,\ /,,/__
\||/ | | | jgs (______Y______)
/\/\/\/\/\/\/\/\//\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
================================================== ============

Trollsdale only does it to annoy.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
Nov 14 '05 #38
Richard Bos wrote:
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote:
Dan Pop wrote:
How about reading the FAQ *before* posting?


Why would Wade read the [C] FAQ *before* posting?


Because it is nothing but polite to read the FAQ for _any_
newsgroup you intend to start posting to. So is reading a
reasonable amount of backlog. It's basic netiquette, really.
Which explains why it's done so rarely :-(

+-------------------+ .:\:\:/:/:.
| PLEASE DO NOT | :.:\:\:/:/:.:
| FEED THE TROLLS | :=.' - - '.=:
| | '=(\ 9 9 /)='
| Thank you, | ( (_) )
| Management | /`-vvv-'\
+-------------------+ / \
| | @@@ / /|,,,,,|\ \
| | @@@ /_// /^\ \\_\
@x@@x@ | | |/ WW( ( ) )WW
\||||/ | | \| __\,,\ /,,/__
\||/ | | | jgs (______Y______)
/\/\/\/\/\/\/\/\//\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
================================================== ============

Trollsdale only does it to annoy.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
Nov 14 '05 #39
Richard Bos wrote:
E. Robert Tisdale wrote:
Dan Pop wrote:
How about reading the FAQ *before* posting?


Why would Wade read the [C] FAQ *before* posting?


Because it is nothing but polite to read the FAQ
for _any_ newsgroup you intend to start posting to.
So is reading a reasonable amount of backlog.
It's basic netiquette, really.
Which explains why it's done so rarely :-(


The C++ FAQ is enormous.
We can't even get regular subscribers to read it.
It isn't reasonable to expect new subscriber to read it
before posting to the comp.lang.c++ newsgroup.
New subscribers are usually just learning C++.
They usually don't have the knowledge required
to understand everything in the C++ FAQ.
Most of the answers are irrelevant
to the questions that new subscribers ask.
You might ask new subscribers
to *search* the C++ FAQ for the answers to their questions
before posting them to the comp.lang.c++ newsgroup
but new subscribers often don't even have the knowledge
required to formulate an efficient query
that will take them to the relevant FAQ.

I don't think that Dan Pop's rhetorical question,
"How about reading the FAQ *before* posting?", was very helpful.
I don't think that Dan Pop was trying to be helpful.
If he wanted to be helpful, he could have posted

The 1.32 FAQ answers to the Wade's question.
http://www.eskimo.com/~scs/C-faq/q1.32.html

as Regis Troadec did.
This directed Wade to a relevant answer to his question
and also told him how to find the FAQ.

I think that Dan is having trouble with self esteem.
His ridicule of other people raises his self esteem
relative to those people. Unfortunately, the effect is temporary
and he must soon find someone else to ridicule.

I don't mean to pick on Dan. There are a lot of nerds and geeks
with the same problem subscribing to this newsgroup
and some people think that this behavior defines us as a group.

Nov 14 '05 #40
E. Robert Tisdale wrote:
The C++ FAQ is enormous.


Of what possible relevance is that assertion to this newsgroup?

Allin Cottrell
Nov 14 '05 #41
"E. Robert Tisdale" wrote:
Richard Bos wrote:
E. Robert Tisdale wrote:
Dan Pop wrote:

How about reading the FAQ *before* posting?

Why would Wade read the [C] FAQ *before* posting?


Because it is nothing but polite to read the FAQ
for _any_ newsgroup you intend to start posting to.
So is reading a reasonable amount of backlog.
It's basic netiquette, really.
Which explains why it's done so rarely :-(


The C++ FAQ is enormous.
We can't even get regular subscribers to read it.
It isn't reasonable to expect new subscriber to read it
before posting to the comp.lang.c++ newsgroup.


As has been said before, Trollsdale only does it to annoy. The
C++ FAQ has absolutely nothing to do with the C language. Also
note his sly 'we'. I doubt that c.l.c++ regulars consider that an
appropriate pronoun.

I am only feeding this troll in order to avoid newbies being
intimidated from FAQ reading.

--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Nov 14 '05 #42
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote:
Richard Bos wrote:
E. Robert Tisdale wrote:
Dan Pop wrote:

How about reading the FAQ *before* posting?

Why would Wade read the [C] FAQ *before* posting?
Because it is nothing but polite to read the FAQ
for _any_ newsgroup you intend to start posting to.
So is reading a reasonable amount of backlog.
It's basic netiquette, really.
Which explains why it's done so rarely :-(


The C++ FAQ is enormous.


That has nothing whatsoever to do with comp.lang.c.
I don't think that Dan Pop was trying to be helpful.
If he wanted to be helpful, he could have posted

The 1.32 FAQ answers to the Wade's question.
http://www.eskimo.com/~scs/C-faq/q1.32.html

as Regis Troadec did.
I agree that this is even better, but that doesn't mean that Dan was
wrong.
I think that Dan is having trouble with self esteem.


While I agree, I note that he is not the only regular on c.l.c whom I
would Freudianise that way *pointed looks*.

Richard
Nov 14 '05 #43
On 7 Apr 2004 06:46:48 -0700, iu*********@yahoo.co.in (anonymous)
wrote:
The FAQ shows the declaration like:

char a[] = "string literal";

But in the OP's question it is like:

char y[] = {"string literal"};

Are they same?


well , It looks same,
I try it with the following code:

int main()
{
char a[]={"12345"};
char b[]="abcdef";
char *p;

pirntf("now a is:%s\n", a);
p=a;
*p='a';
printf("now a is:%s\n", p);

printf("now b is:%s\n", b);
p=b;
*(p+1)='1';
printf("now b is:%s\n", p);

return 0;
}

the output is like this:
now a is:12345
now a is:a2345
now b is: abcdef
now b is: 1bcdef

so , I changed the value with a point 'p'...
Wade
Nov 14 '05 #44
In <40************@jpl.nasa.gov> "E. Robert Tisdale" <E.**************@jpl.nasa.gov> writes:
I don't think that Dan Pop's rhetorical question,
"How about reading the FAQ *before* posting?", was very helpful.
It was extremely helpful. Regardless of what you think.
I don't think that Dan Pop was trying to be helpful.
If he wanted to be helpful, he could have posted

The 1.32 FAQ answers to the Wade's question.
http://www.eskimo.com/~scs/C-faq/q1.32.html

as Regis Troadec did.
This directed Wade to a relevant answer to his question
and also told him how to find the FAQ.


Spoonfeeding the lazy posters to this newsgroup merely passes the wrong
message to other newbies: "don't bother reading the FAQ yourself, someone
who has already done it will give you a complete reference, or even
quote the text so that you don't have to bother finding the FAQ".

Therefore, I include a reference ONLY when it is not immediately obvious
that the FAQ question actually covers the poster's issue.

As to finding the location of the FAQ, some people have already heard
about Google. Type "comp.lang.c FAQ" and click on "I'm Feeling Lucky".

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #45
On Thu, 08 Apr 2004 17:17:05 +0800, Wade Yin <wa*****@tom.com> wrote:
On 7 Apr 2004 06:46:48 -0700, iu*********@yahoo.co.in (anonymous)
wrote:
The FAQ shows the declaration like:

char a[] = "string literal";

But in the OP's question it is like:

char y[] = {"string literal"};

Are they same?
well , It looks same,
I try it with the following code:

int main()
{
char a[]={"12345"};
char b[]="abcdef";
char *p;

pirntf("now a is:%s\n", a);


Must be an extension unique to your compiler.
p=a;
*p='a';
printf("now a is:%s\n", p);

printf("now b is:%s\n", b);
p=b;
*(p+1)='1';
printf("now b is:%s\n", p);

return 0;
}

the output is like this:
now a is:12345
now a is:a2345
now b is: abcdef
There is no leading space in the initialization of b. There no space
between the : and the % in the format string. Why is there a space in
your output?
now b is: 1bcdef
Surely you meant a1cdef.

so , I changed the value with a point 'p'...

Please cut and paste your code, don't retype it. Same for output.
<<Remove the del for email>>
Nov 14 '05 #46
[Sorry about replying two links down the line, the former messages
have expired from my server.]
Richard Bos wrote:
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote:
Dan Pop wrote:

How about reading the FAQ *before* posting?

Why would Wade read the [C] FAQ *before* posting?


Because it is nothing but polite to read the FAQ for _any_
newsgroup you intend to start posting to.


Actually, ERT might have a point here, although probably *not* the one
(s)he intended: Wade should have read the FAQ *instead of* posting :-)

Peter
Nov 14 '05 #47
On 9 Apr 2004 01:11:30 GMT, Barry Schwarz <sc******@deloz.net> wrote:
On Thu, 08 Apr 2004 17:17:05 +0800, Wade Yin <wa*****@tom.com> wrote:
On 7 Apr 2004 06:46:48 -0700, iu*********@yahoo.co.in (anonymous)
wrote:
char a[] = "string literal"; char y[] = {"string literal"};

Are they same?


well , It looks same,
I try it with the following code: char a[]={"12345"};
char b[]="abcdef";
char *p;

pirntf("now a is:%s\n", a);


Must be an extension unique to your compiler.

Nope. C99 6.7.8p14 unchanged from C90 6.5.7:
An array of character type may be initialized by a character string
literal, optionally
enclosed in braces. Successive characters of the character string
literal (including the
terminating null character if there is room or if the array is of
unknown size) initialize the
elements of the array.

- David.Thompson1 at worldnet.att.net
Nov 14 '05 #48
On Mon, 12 Apr 2004 02:26:37 GMT, Dave Thompson
<da*************@worldnet.att.net> wrote:
On 9 Apr 2004 01:11:30 GMT, Barry Schwarz <sc******@deloz.net> wrote:
On Thu, 08 Apr 2004 17:17:05 +0800, Wade Yin <wa*****@tom.com> wrote:
>On 7 Apr 2004 06:46:48 -0700, iu*********@yahoo.co.in (anonymous)
>wrote: >>char a[] = "string literal"; >>char y[] = {"string literal"};
>>
>>Are they same?
>
>well , It looks same,
>I try it with the following code: > char a[]={"12345"};
> char b[]="abcdef";
> char *p;
>
> pirntf("now a is:%s\n", a);


Must be an extension unique to your compiler.

Nope. C99 6.7.8p14 unchanged from C90 6.5.7:
An array of character type may be initialized by a character string
literal, optionally
enclosed in braces. Successive characters of the character string
literal (including the
terminating null character if there is room or if the array is of
unknown size) initialize the
elements of the array.


My comment was on the function call, not the array initialization.
Where is the prototype for ***pirntf*** on your compiler?

<<Remove the del for email>>
Nov 14 '05 #49

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Guybrush Threepwood | last post by:
Hi, I was always wondering if there is any difference between void someFunction(int,int) and void someFunction(int A, int B) is there?
9
by: Vipul Jain | last post by:
Can any one please tell me what is the difference between global scope of an variable and file scope of an variable. Vipul
30
by: Wade Yin | last post by:
Hi, What's the difference between: char *x="abcde"; and char y={"abcde"};
18
by: Vasileios Zografos | last post by:
Hello, can anyone please tell me if there is any difference between the two: double Array1; and
0
suzee_q00
by: suzee_q00 | last post by:
I will go ahead and give you a little background for what I am working on, though I have been hazy on pointers for some time. I get that a pointer points to an address in memory. Today I just...
132
by: Frederick Gotham | last post by:
If we look at a programming language such as C++: When an updated Standard comes out, everyone adopts it and abandons the previous one. It seems though that things aren't so clear-cut in the C...
9
by: Gummy | last post by:
Hello, I created a user control that has a ListBox and a RadioButtonList (and other stuff). The idea is that I put the user control on the ASPX page multiple times and each user control will...
10
by: Ahmad Humayun | last post by:
Whats the difference between: char str1 = "wxyz"; char* str2 = "abcd"; I can do this: str2 = str1 but I can't do this: str1 = str2
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.