473,386 Members | 1,860 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,386 software developers and data experts.

String pointers and string arrays

In following code
char str[] = "asdf" ;
str[0] = 's' ;
is possible.

But char *str = "asdf" ;
str[0] = 's' ;
is an run-time error.

What i understand is *str = "asdf" is stored in Read-only-Memory. Where
as str[] is stored in stack.

Does any body has any better explanation for that?

Feb 10 '06 #1
32 2532

santosh wrote:
In following code
char str[] = "asdf" ;
str[0] = 's' ;
is possible.

But char *str = "asdf" ;
str[0] = 's' ;
is an run-time error.

What i understand is *str = "asdf" is stored in Read-only-Memory. Where
as str[] is stored in stack.

Does any body has any better explanation for that?


str[] is a copy of the data "asdf"
*str points to "asdf" itself.

Feb 10 '06 #2
tmp123 wrote:
santosh wrote:
In following code
char str[] = "asdf" ;
str[0] = 's' ;
is possible.

But char *str = "asdf" ;
str[0] = 's' ;
is an run-time error.

What i understand is *str = "asdf" is stored in Read-only-Memory. Where
as str[] is stored in stack.

Does any body has any better explanation for that?


str[] is a copy of the data "asdf"
*str points to "asdf" itself.


And in addition to that, it's undefined behavior to modify
a string litteral - which is what he did in the pointer
case.
Feb 10 '06 #3
santosh wrote:
In following code
char str[] = "asdf" ;
str[0] = 's' ;
is possible.

But char *str = "asdf" ;
str[0] = 's' ;
is an run-time error.
.... on some implementations ...
What i understand is *str = "asdf" is stored in Read-only-Memory. Where
as str[] is stored in stack.

Does any body has any better explanation for that?


It is Not Allowed to update string literals, so if you do it, anything
may happen. Some machines will crash, some will alter the literal, some
will overwrite [pseudo] random memory, some will write libellous emails
to your local head of state.

Some implementations have a stack, but `str[]` need not be on it.
Some implementations have read-only memory, but "" need not be in it.

But it is Not Allowed to update string literals.

--
Chris "try, or try not -- there is no do" Dollin
Feb 10 '06 #4
As you said I did a test of memory access:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <malloc.h> /* ptrdiff_t */
#include <alloca.h> /* only test alloca */
#include <string.h>

extern void afunc(void);

int bss_var; /* Auto init to 0 ,should be in BSS */
int data_var = 42; /* Init is not 0, should be in Data Sigment */

int main(int argc,char **argv){
char *p,*b,*nb;
char *str ="aaa";
char s[] = "aaa";
char *pt =NULL;

pt = (char *)malloc(sizeof(char *) * 5);

strcpy(pt,"aaa");

printf("Text locations:\n");
printf("\tAddress of main:%p\n",main);
printf("\tAddress of afunc:%p\n",afunc);

printf("Stack Locations:\n");
afunc();

p = (char *)alloca(32);
if(p != NULL){
printf("\tStart of alloca()'ed array : %p\n",p);
printf("\tEnd of alloca()'ed array : %p\n",p+31);
}

printf("Data Locations:\n");
printf("\tAddress of data_var : %p\n", & data_var);

printf("BSS Locations:\n");
printf("\tAddress of bss_var : %p\n", & bss_var);

b = sbrk((ptrdiff_t) 32); /* increase mem size */
nb = sbrk((ptrdiff_t) 0); /* get mem end address */
printf("Heap Locations: \n");
printf("\tInitial end of heap: %p\n",b);
printf("\tNew end of heap: %p\n",nb);

b = sbrk((ptrdiff_t) -16); /* decrease mem size */
nb = sbrk((ptrdiff_t) 0);
printf("\tFinal end of heap : %p\n",nb);

printf("str:%p\n",str);
printf("s:%p\n",s);
printf("pt:%p\n",pt);
return 0;
}

void afunc(void){
static int level = 0;
auto int stack_var;

if(++level == 5){
return;
}
printf("\tStack level %d: address of stack_var: %p\n",level, &
stack_var);

afunc(); /* cycle */
}
-----------------------------------------------
And result is:

Text locations:
Address of main:0x80483c4
Address of afunc:0x80485a8
Stack Locations:
Stack level 1: address of stack_var: 0xbfffe124
Stack level 2: address of stack_var: 0xbfffe114
Stack level 3: address of stack_var: 0xbfffe104
Stack level 4: address of stack_var: 0xbfffe0f4
Start of alloca()'ed array : 0xbfffe110
End of alloca()'ed array : 0xbfffe12f
Data Locations:
Address of data_var : 0x804989c
BSS Locations:
Address of bss_var : 0x80499a8
Heap Locations:
Initial end of heap: 0x804b000
New end of heap: 0x804b020
Final end of heap : 0x804b010

str:0x80486c0
s:0xbfffe134
pt:0x8049a00
-----------------------------------------------------------------------------------

If you want to do that I guess source will be :

#include <stdio.h>
#include <string.h>

int main(void){
char *str = NULL;

str = (char *)malloc(sizeof(char *)*5);
strcpy(str,"abcd");
str[0] = 's' ;

printf("%s\n",str);
free(str);
return 0;
}

santosh wrote:
In following code
char str[] = "asdf" ;
str[0] = 's' ;
is possible.

But char *str = "asdf" ;
str[0] = 's' ;
is an run-time error.

What i understand is *str = "asdf" is stored in Read-only-Memory. Where
as str[] is stored in stack.

Does any body has any better explanation for that?


Feb 10 '06 #5
"santosh" <sa***********@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
In following code
char str[] = "asdf" ;
str[0] = 's' ;
is possible.
That means: str is an array of char, its length is 4 and it is initialized
to "asdf". Initial value can be changed later on.
But char *str = "asdf" ;
str[0] = 's' ;
is an run-time error.


That means: str points to the string literal "asdf". So what you are trying
to to is something like: "asdf"[0]='s'; I do not think that is generally
allowed.
Feb 10 '06 #6

santosh wrote:
In following code
char str[] = "asdf" ;
This as equivalent to:

char str[] = {'a', 's', 'd', 'f', \0};

A normal way to initialise arrays.
str[0] = 's' ;
is possible.

But char *str = "asdf" ;
This creates a nameless /constant/ string literal "asdf", and you're
not allowed to modify constants, as it invokes Undefined Behaviour, and
you /know/ what /that/ means (close your eyes, and imagine demons
flying out your nose -- pink ones)!
What i understand is *str = "asdf" is stored in Read-only-Memory. Where
as str[] is stored in stack.


No, see above.

--
BR, Vladimir

Feb 10 '06 #7
santosh a écrit :
In following code
char str[] = "asdf" ;
Here is an initialized array of char.
str[0] = 's' ;
is possible.
Sure. An array of char is mutable (unless it is qualified 'const').
But char *str = "asdf" ;
Here is a pointer to a string literal.
str[0] = 's' ;
Undefine behaviour. A string literal is not portably mutable. You'd
better code this :

char const *str = "asdf" ;

It makes things clear. Any attempt to modify the string :

str[0] = 's' ;

will ring a bell.

Much better. If you have gcc, add the -Wwrite-strings flag on the
command line.
is an run-time error.
It's possible. An undefined behaviour can produce anything at all event
nothing visible (today).
What i understand is *str = "asdf" is stored in Read-only-Memory. Where
It's compiler dependent.
as str[] is stored in stack.
If you meant 'automatic memory', yes, possibly, or 'static memory'...
who knows. We need more code...
Does any body has any better explanation for that?


No, but the standard surely has one:

http://www.open-std.org/jtc1/sc22/wg...docs/n1124.pdf

--
A+

Emmanuel Delahaye
Feb 10 '06 #8
Vladimir S. Oka wrote:

santosh wrote:
In following code
char str[] = "asdf" ;
This as equivalent to:

char str[] = {'a', 's', 'd', 'f', \0};

A normal way to initialise arrays.
str[0] = 's' ;
is possible.

But char *str = "asdf" ;


This creates a nameless /constant/ string literal "asdf", and you're
not allowed to modify constants, as it invokes Undefined Behaviour,
and you /know/ what /that/ means (close your eyes, and imagine demons
flying out your nose -- pink ones)!


I forgot to add: the address of the string literal is then assigned to
the pointer `str`. No arrays in sight there...
What i understand is *str = "asdf" is stored in Read-only-Memory.
Where as str[] is stored in stack.


No, see above.

--
BR, Vladimir


--
BR, Vladimir

Human beings were created by water to transport it uphill.

Feb 10 '06 #9

"santosh" <sa***********@gmail.com> writes:
In following code
char str[] = "asdf" ;
str[0] = 's' ;
is possible.

But char *str = "asdf" ;
str[0] = 's' ;
is an run-time error.

What i understand is *str = "asdf" is stored in Read-only-Memory. Where
as str[] is stored in stack.

Does any body has any better explanation for that?


Where they are stored, and whether the program is allowed to change
them according to C semantics, and whether it can actually do so, are
different things. Consider the keywords "static" and "const" too.

Some compilers can give you warnings when you try to change values
illegally:

int main()
{
char s1[] = "asfd";
const char s2[] = "asfd";
static char s3[] = "asfd";
static const char s4[] = "asfd";

s1[0] = 'b';
s2[0] = 'b'; /* line 9 */
s3[0] = 'b';
s4[0] = 'b'; /* line 11 */

return 0;
}

% gcc -c const.c
const.c: In function `main':
const.c:9: warning: assignment of read-only location
const.c:11: warning: assignment of read-only location
Feb 10 '06 #10
"Ro*****@gmail.com" wrote:

As you said I did a test of memory access:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
Not a standard include file
#include <malloc.h> /* ptrdiff_t */
Not a standard include file. ptrdiff_t is defined in stddef.h.
#include <alloca.h> /* only test alloca */


Not a standard include file

Please do not post non-standard code here. It is off-topic. Also,
please do not top-post. Your reply should follow, or be intermixed
with, the material you quote (after snipping of non-relevant
material).

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>
Feb 10 '06 #11
Vladimir S. Oka wrote:
I forgot to add: the address of the string literal is then assigned to
the pointer `str`. No arrays in sight there...


The string literal represents an array.
The type of "abcd", is an array of 5 char.

--
pete
Feb 10 '06 #12
pete wrote:
Vladimir S. Oka wrote:
I forgot to add: the address of the string literal is then assigned
to the pointer `str`. No arrays in sight there...


The string literal represents an array.
The type of "abcd", is an array of 5 char.


Yes, you're right. Thanks.

--
BR, Vladimir

"I haven't lost my mind; I know exactly where I left it."

Feb 10 '06 #13
"santosh" <sa***********@gmail.com> writes:
In following code
char str[] = "asdf" ;
str[0] = 's' ;
is possible.

But char *str = "asdf" ;
str[0] = 's' ;
is an run-time error.

What i understand is *str = "asdf" is stored in Read-only-Memory. Where
as str[] is stored in stack.

Does any body has any better explanation for that?


Yes, Steve Summit does. This is question 1.32 in the comp.lang.c FAQ,
<http://www.c-faq.com/>.

A note to the comp.lang.c regulars: I think we need to make better use
of the FAQ. I see a lot of people spending time answering FAQs
without referring to the FAQ list. Often a simple reference to the
FAQ list is all that's required.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Feb 10 '06 #14
On 10 Feb 2006 06:38:12 -0800, "Vladimir S. Oka"
<no****@btopenworld.com> wrote in comp.lang.c:

santosh wrote:
In following code
char str[] = "asdf" ;


This as equivalent to:

char str[] = {'a', 's', 'd', 'f', \0};

A normal way to initialise arrays.
str[0] = 's' ;
is possible.

But char *str = "asdf" ;


This creates a nameless /constant/ string literal "asdf", and you're


[snip]

No, it does not. The type of a string literal in C is "array of
char", and most specifically not "array of const char".

Attempting to modify a string literal in C is undefined behavior
because the standard explicitly states that it is, not because the
string literal exists in an array of const chars.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
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
Feb 11 '06 #15
santosh wrote:
In following code
char str[] = "asdf" ;
str[0] = 's' ;
is possible.

But char *str = "asdf" ;
str[0] = 's' ;
is an run-time error.

What i understand is *str = "asdf" is stored in Read-only-Memory. Where
as str[] is stored in stack.

Does any body has any better explanation for that?


In the first, you are specifying an array with storage pegged to the
scope of where you are declaring it. So its storage is either in
function scope or file scope. The ="asdf"; part specifies how the
initial storage is initialized. Modifying str[0] is modifying its base
storage, and since its not declared const, there is no problem doing
this.

The second is a declaration of the pointer in which no specific storage
is specified. So "asdf" is given *implicit* storage in some unknown
but static location. The compiler is allowed to reuse this memory and
can assume it is never modified if it likes, so trying to modify it at
runtime is undefined. So the ="asdf"; part has a different meaning
here than it did in the prior declaration.

Note also that: char str[10] = NULL; is also illegal, however char *
str = NULL; is not. The reason is that in the first, the initializer
must specify contents for what is being stored in str[10], while in the
second you are not specifying storage at all, which is fine for a
pointer.

--
Paul Hsieh
http://www.pobox.com/~qed/
http://bstring.sf.net/

Feb 11 '06 #16
Keith Thompson wrote:
.... snip ...
A note to the comp.lang.c regulars: I think we need to make better
use of the FAQ. I see a lot of people spending time answering
FAQs without referring to the FAQ list. Often a simple reference
to the FAQ list is all that's required.


I agree in principle, but not in practice. The problem is that
most of the questioners never heard of the FAQ, and almost
certainly don't have it at their fingertips. That is their fault,
not ours. But one of our campaigns here must be to defeat
ignorance.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>
Feb 12 '06 #17
we******@gmail.com wrote:
santosh wrote:

What i understand is *str = "asdf" is stored in Read-only-Memory. Where
as str[] is stored in stack.

Does any body has any better explanation for that?
In the first, you are specifying an array with storage pegged to the
scope of where you are declaring it. So its storage is either in
function scope or file scope.


Storage is not in any scope. "Scope" refers to the parts of a
program where an identifier is visible. That identifier could have
any sort of storage (or even none at all).
The ="asdf"; part specifies how the initial storage is initialized.
Modifying str[0] is modifying its base storage,
There is no such thing as "initial storage" and "base storage".
Each variable only has one storage area and I think it is
confusing to give it extra labels like that.
and since its not declared const, there is no problem doing this. The second is a declaration of the pointer in which no specific storage
is specified. So "asdf" is given *implicit* storage in some unknown
but static location.
"asdf" is an array of char that has storage just like any other array.
Again, giving storage labels like "specific" and "implicit" is just
confusing, IMHO.

Whether or not a pointer gets pointed to this, makes no difference
as to how or where it is allocated (or what name we should call it!)
The compiler is allowed to reuse this memory and
can assume it is never modified if it likes, so trying to modify it at
runtime is undefined. So the ="asdf"; part has a different meaning
here than it did in the prior declaration.
The "asdf" part has the same meaning and the '=' have
the same meaning. In both cases, the array "asdf" is being
used to initialize the variable on the left.

But arrays are initialized by another objects which are
copied into them (to cut a long story short), whereas pointers
are initialized by pointing them to an object.
Note also that: char str[10] = NULL; is also illegal,
This is legal and initializes str to contain null characters.
(A null pointer constant can be converted to an integer).
However it's bad style.
however char * str = NULL; is not. The reason is that in
the first, the initializer must specify contents for what is
being stored in str[10], while in the second you are not
specifying storage at all, which is fine for a pointer.


Pointers, just like any other variable, have storage.
In both examples the storage is being initailized.

Feb 12 '06 #18
CBFalconer <cb********@yahoo.com> writes:
Keith Thompson wrote:

... snip ...

A note to the comp.lang.c regulars: I think we need to make better
use of the FAQ. I see a lot of people spending time answering
FAQs without referring to the FAQ list. Often a simple reference
to the FAQ list is all that's required.


I agree in principle, but not in practice. The problem is that
most of the questioners never heard of the FAQ, and almost
certainly don't have it at their fingertips. That is their fault,
not ours. But one of our campaigns here must be to defeat
ignorance.


My point is that I often see regulars, people who know about the FAQ,
posting lengthy (and usually correct) explanations that duplicate the
information that's already in the FAQ. (I've probably done this
myself.) The regulars aren't making as much use of the FAQ as we
could.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Feb 12 '06 #19
Old Wolf wrote:
In the first, you are specifying an array with storage pegged to the
scope of where you are declaring it. So its storage is either in
function scope or file scope.
Storage is not in any scope. "Scope" refers to the parts of a
program where an identifier is visible. That identifier could have
any sort of storage (or even none at all).


Identifiers have scope, objects have storage.
static and automatic declared objects,
have identifiers which are also primary expressions.

"asdf" is an array of char that has storage just like any other array.
Again, giving storage labels like "specific" and "implicit" is just
confusing, IMHO.

Whether or not a pointer gets pointed to this, makes no difference
as to how or where it is allocated (or what name we should call it!)
"reserved" is a better word to apply to storage than "allocated",
since "allocated" is one of the 3 kinds of duration.
The "asdf" part has the same meaning and the '=' have
the same meaning.


The meaning is different.
When initializing an array like:

char array[] = "";

.... the "" means the exact same thing as {'\0'}
and the = is used here in a way that can't be used
with an array anywhere else except in a declaration.

When initializing a pointer like:

char *array = "";

The "" is an expression of array type
which gets converted to a pointer to its first member.
The = is used here in a way that is very similar
to assignment, as in an assignment expression.
Note also that: char str[10] = NULL; is also illegal,


This is legal and initializes str to contain null characters.


It is not legal.
Initialization of aggregate types requires {braces}.

--
pete
Feb 12 '06 #20

"Keith Thompson" <ks***@mib.org> wrote in message
news:ln************@nuthaus.mib.org...
CBFalconer <cb********@yahoo.com> writes:
Keith Thompson wrote:

... snip ...

A note to the comp.lang.c regulars: I think we need to make better
use of the FAQ. I see a lot of people spending time answering
FAQs without referring to the FAQ list. Often a simple reference
to the FAQ list is all that's required.


I agree in principle, but not in practice. The problem is that
most of the questioners never heard of the FAQ, and almost
certainly don't have it at their fingertips. That is their fault,
not ours. But one of our campaigns here must be to defeat
ignorance.


My point is that I often see regulars, people who know about the FAQ,
posting lengthy (and usually correct) explanations that duplicate the
information that's already in the FAQ. (I've probably done this
myself.) The regulars aren't making as much use of the FAQ as we
could.


Tag. Your it. Post it once a month. Simple.
Rod Pemberton
Feb 12 '06 #21
pete wrote:
Old Wolf wrote:


<snip>
Note also that: char str[10] = NULL; is also illegal,

This is legal and initializes str to contain null characters.


It is not legal.
Initialization of aggregate types requires {braces}.


Also NULL could expand to an expression of pointer type, e.g.
((void*)0), in which case even with the braces it would fail unless you
also cast it to an integer type.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Feb 12 '06 #22
On Sat, 11 Feb 2006 22:14:04 -0500, in comp.lang.c , CBFalconer
<cb********@yahoo.com> wrote:
Keith Thompson wrote:

... snip ...

A note to the comp.lang.c regulars: I think we need to make better
use of the FAQ. I see a lot of people spending time answering
FAQs without referring to the FAQ list. Often a simple reference
to the FAQ list is all that's required.


I agree in principle, but not in practice. The problem is that
most of the questioners never heard of the FAQ, and almost
certainly don't have it at their fingertips.


Its not that hard to say

"Its a FAQ - read my sig"

Mark McIntyre
--
CLC FAQ <http://c-faq.com/>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Feb 13 '06 #23
On Sun, 12 Feb 2006 08:52:19 -0500, in comp.lang.c , "Rod Pemberton"
<do*********@sorry.bitbucket.cmm> wrote:
Tag. Your it. Post it once a month. Simple.


The copyright holder already does that. Post a link. Even simpler

Mark McIntyre
--
CLC FAQ <http://c-faq.com/>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Feb 13 '06 #24
Mark McIntyre wrote:
<cb********@yahoo.com> wrote:
Keith Thompson wrote:

... snip ...

A note to the comp.lang.c regulars: I think we need to make better
use of the FAQ. I see a lot of people spending time answering
FAQs without referring to the FAQ list. Often a simple reference
to the FAQ list is all that's required.


I agree in principle, but not in practice. The problem is that
most of the questioners never heard of the FAQ, and almost
certainly don't have it at their fingertips.


Its not that hard to say

"Its a FAQ - read my sig"


But they're not going to do it. Many of these newbies are using
google. Going off to read a reference is quite likely a major
expedition for them, and would involve losing track of where they
are in reading our (collective) golden verbiage, with no known way
(for them) of placing a marker and coming back. They are probably
using such evil things as Outhouse (maximized to cover the entire
screen) for access.

That's why I persist in having both instructions and references in
my 'Google' sig. even though it makes it exceed four lines.

--
"The power of the Executive to cast a man into prison without
formulating any charge known to the law, and particularly to
deny him the judgement of his peers, is in the highest degree
odious and is the foundation of all totalitarian government
whether Nazi or Communist." -- W. Churchill, Nov 21, 1943
Feb 13 '06 #25
CBFalconer <cb********@yahoo.com> writes:
Mark McIntyre wrote:
<cb********@yahoo.com> wrote:
Keith Thompson wrote:

... snip ...

A note to the comp.lang.c regulars: I think we need to make better
use of the FAQ. I see a lot of people spending time answering
FAQs without referring to the FAQ list. Often a simple reference
to the FAQ list is all that's required.

I agree in principle, but not in practice. The problem is that
most of the questioners never heard of the FAQ, and almost
certainly don't have it at their fingertips.


Its not that hard to say

"Its a FAQ - read my sig"


But they're not going to do it. Many of these newbies are using
google. Going off to read a reference is quite likely a major
expedition for them, and would involve losing track of where they
are in reading our (collective) golden verbiage, with no known way
(for them) of placing a marker and coming back. They are probably
using such evil things as Outhouse (maximized to cover the entire
screen) for access.


As far as I know, news.google.com can only be accessed through a web
browser (I don't think Google provides an NNTP server). Following a
link should be *easier* for Googlers than for the rest of us.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Feb 13 '06 #26
Keith Thompson wrote:
CBFalconer <cb********@yahoo.com> writes:
Mark McIntyre wrote:
<cb********@yahoo.com> wrote:
Keith Thompson wrote:
>
... snip ...
>
> A note to the comp.lang.c regulars: I think we need to make better
> use of the FAQ. I see a lot of people spending time answering
> FAQs without referring to the FAQ list. Often a simple reference
> to the FAQ list is all that's required.

I agree in principle, but not in practice. The problem is that
most of the questioners never heard of the FAQ, and almost
certainly don't have it at their fingertips.

Its not that hard to say

"Its a FAQ - read my sig"


But they're not going to do it. Many of these newbies are using
google. Going off to read a reference is quite likely a major
expedition for them, and would involve losing track of where they
are in reading our (collective) golden verbiage, with no known way
(for them) of placing a marker and coming back. They are probably
using such evil things as Outhouse (maximized to cover the entire
screen) for access.


As far as I know, news.google.com can only be accessed through a web
browser (I don't think Google provides an NNTP server). Following a
link should be *easier* for Googlers than for the rest of us.


Following, yes. Returning, no. IE doesn't have such handy things
as the Firefox tabs AFAIK (I haven't touched Exploder in years).
At any rate the first time a googlepuss follows something, and
can't easily return, he is taught not to follow things.

--
"The power of the Executive to cast a man into prison without
formulating any charge known to the law, and particularly to
deny him the judgement of his peers, is in the highest degree
odious and is the foundation of all totalitarian government
whether Nazi or Communist." -- W. Churchill, Nov 21, 1943
Feb 13 '06 #27
CBFalconer wrote:
Keith Thompson wrote:
CBFalconer <cb********@yahoo.com> writes:
Mark McIntyre wrote:
<cb********@yahoo.com> wrote:
> Keith Thompson wrote:
> ... snip ...
>> A note to the comp.lang.c regulars: I think we need to make better
>> use of the FAQ. I see a lot of people spending time answering
>> FAQs without referring to the FAQ list. Often a simple reference
>> to the FAQ list is all that's required.
> I agree in principle, but not in practice. The problem is that
> most of the questioners never heard of the FAQ, and almost
> certainly don't have it at their fingertips.
Its not that hard to say

"Its a FAQ - read my sig"
But they're not going to do it. Many of these newbies are using
google. Going off to read a reference is quite likely a major
expedition for them, and would involve losing track of where they
are in reading our (collective) golden verbiage, with no known way
(for them) of placing a marker and coming back. They are probably
using such evil things as Outhouse (maximized to cover the entire
screen) for access.

As far as I know, news.google.com can only be accessed through a web
browser (I don't think Google provides an NNTP server). Following a
link should be *easier* for Googlers than for the rest of us.


Following, yes. Returning, no. IE doesn't have such handy things
as the Firefox tabs AFAIK (I haven't touched Exploder in years).
At any rate the first time a googlepuss follows something, and
can't easily return, he is taught not to follow things.


In IE you can always open a new window when clicking on a link, so if
someone complains about that tell them to right click and open it in a
new window. On IE7 as I have it configured clicking on a link in Google
opened the URL in a new tab. I could check IE6 but that requires running
up a virtual machine.
--
Flash Gordon
Living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidlines and intro -
http://clc-wiki.net/wiki/Intro_to_clc
Feb 13 '06 #28
CBFalconer wrote:
Keith Thompson wrote:

As far as I know, news.google.com can only be accessed through a web
browser (I don't think Google provides an NNTP server). Following a
link should be easier for Googlers than for the rest of us.


Following, yes. Returning, no. IE doesn't have such handy things
as the Firefox tabs AFAIK (I haven't touched Exploder in years).
At any rate the first time a googlepuss follows something, and
can't easily return, he is taught not to follow things.


IE does provide for opening a link in a new window. Also, the standard
navigation capability should bring the user back to the message window.
Brian
Feb 13 '06 #29
CBFalconer <cb********@yahoo.com> writes:
Keith Thompson wrote:
CBFalconer <cb********@yahoo.com> writes:
Mark McIntyre wrote:
<cb********@yahoo.com> wrote:
> Keith Thompson wrote:
>>
>... snip ...
>>
>> A note to the comp.lang.c regulars: I think we need to make better
>> use of the FAQ. I see a lot of people spending time answering
>> FAQs without referring to the FAQ list. Often a simple reference
>> to the FAQ list is all that's required.
>
> I agree in principle, but not in practice. The problem is that
> most of the questioners never heard of the FAQ, and almost
> certainly don't have it at their fingertips.

Its not that hard to say

"Its a FAQ - read my sig"

But they're not going to do it. Many of these newbies are using
google. Going off to read a reference is quite likely a major
expedition for them, and would involve losing track of where they
are in reading our (collective) golden verbiage, with no known way
(for them) of placing a marker and coming back. They are probably
using such evil things as Outhouse (maximized to cover the entire
screen) for access.


As far as I know, news.google.com can only be accessed through a web
browser (I don't think Google provides an NNTP server). Following a
link should be *easier* for Googlers than for the rest of us.


Following, yes. Returning, no. IE doesn't have such handy things
as the Firefox tabs AFAIK (I haven't touched Exploder in years).
At any rate the first time a googlepuss follows something, and
can't easily return, he is taught not to follow things.


Huh??

I've never seen a web browser, IE included, that didn't have a "back"
button. Following a link and going back to where you came from is
*trivial*. It's also easy to open a link in a new window.

In any case, my original point was simply that we're not making very
good use of the FAQ. If you think following a link is too difficult,
you could always copy-and-paste the FAQ entry into your response
rather than composing an answer from scratch.

If someone asks

Why doesn't strcat(string, '!'); work?

the *only* necessary response is:

See the comp.lang.c FAQ, <http://www.c-faq.com/>, question 8.1.

And if half a dozen of us post the same thing (due to the asynchronous
nature of Usenet), maybe the idea that posters should check the FAQ
before posting would start to sink in.

If someone comes back and says, "Following that link is much too
difficult for me, please spoon-feed me the answer", we can then decide
what to do next.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Feb 13 '06 #30
Keith Thompson wrote:
.... snip ...
I've never seen a web browser, IE included, that didn't have a "back"
button. Following a link and going back to where you came from is
*trivial*. It's also easy to open a link in a new window.

In any case, my original point was simply that we're not making very
good use of the FAQ. If you think following a link is too difficult,
you could always copy-and-paste the FAQ entry into your response
rather than composing an answer from scratch.

If someone asks

Why doesn't strcat(string, '!'); work?

the *only* necessary response is:

See the comp.lang.c FAQ, <http://www.c-faq.com/>, question 8.1.

And if half a dozen of us post the same thing (due to the asynchronous
nature of Usenet), maybe the idea that posters should check the FAQ
before posting would start to sink in.

If someone comes back and says, "Following that link is much too
difficult for me, please spoon-feed me the answer", we can then decide
what to do next.


As I said way back, I agree in principle. However a couple of
lines to answer a question is not much more effort than a faq ref,
and may be much less. I, for one, would take some time and effort
to find the appropriate faq ref. Lets face it, the supply of
newbies will always exceed the training of same. Some get all hot
under the collar when referred elsewhere, so the existence of a
variety of fairly accurate replies is no fault.

Ideally the question doesn't get asked in the first place, because
the faq has been consulted and is clear to the neophyte. But this
may not work, and reminds me of my own problems teaching newbies.
I tend to give a perfectly coherent and comprehensive explanation
of something that is second nature to me, and receive a blank
look. This results in repeating the aforesaid explanation with
slight variation in emphasis and volume, and the same blank look.
Now what can I do?

I have seen better teachers than I give less comprehensive (and
less accurate) explanations, and been instantly understood by those
same blank-faced newbies. This is a talent to be respected. I do
not have it.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>

Feb 14 '06 #31
Vladimir, gostaria de tirar uma duvida sobre ponteiros!!
Como inverter os valores de um ponteiro assim como faço com simples
vetores de caracter?

Feb 14 '06 #32
On Mon, 13 Feb 2006 18:40:34 -0500, CBFalconer <cb********@yahoo.com>
wrote:
Keith Thompson wrote:
... snip ...

In any case, my original point was simply that we're not making very
good use of the FAQ. If you think following a link is too difficult,
you could always copy-and-paste the FAQ entry into your response
rather than composing an answer from scratch.

If someone asks

Why doesn't strcat(string, '!'); work?

the *only* necessary response is:

See the comp.lang.c FAQ, <http://www.c-faq.com/>, question 8.1.

And if half a dozen of us post the same thing (due to the asynchronous
nature of Usenet), maybe the idea that posters should check the FAQ
before posting would start to sink in.

If someone comes back and says, "Following that link is much too
difficult for me, please spoon-feed me the answer", we can then decide
what to do next.


As I said way back, I agree in principle. However a couple of
lines to answer a question is not much more effort than a faq ref,


i agree; there are case where a couple of words is enough
and may be much less. I, for one, would take some time and effort
to find the appropriate faq ref. Lets face it, the supply of
newbies will always exceed the training of same. Some get all hot
under the collar when referred elsewhere, so the existence of a
variety of fairly accurate replies is no fault.

Ideally the question doesn't get asked in the first place, because
the faq has been consulted and is clear to the neophyte. But this
may not work, and reminds me of my own problems teaching newbies.
I tend to give a perfectly coherent and comprehensive explanation
of something that is second nature to me, and receive a blank
look. This results in repeating the aforesaid explanation with
slight variation in emphasis and volume, and the same blank look.
Now what can I do?

I have seen better teachers than I give less comprehensive (and
less accurate) explanations, and been instantly understood by those
same blank-faced newbies. This is a talent to be respected. I do
not have it.


i think your problem is only you take too much time for NGs
(as many others) your post are very helpful
Feb 15 '06 #33

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

Similar topics

11
by: Linny | last post by:
Hi, I need some help in declaring an array of pointers to array of a certain fixed size. I want the pointers to point to arrays of fixed size only (should not work for variable sized arrays of the...
28
by: Davy | last post by:
Hi all, I found char x={"my"}; can be compiled. But char x; x={"my"}; can not be compiled.
4
by: Robert | last post by:
Hi, How can i resize an array of strings to add more? This is an example i just downloaded from a website: char *cpArray; int i; for (i = 0; i < 10; i++) cpArray = (char *)malloc(20 *...
7
by: al | last post by:
char s = "This string literal"; or char *s= "This string literal"; Both define a string literal. Both suppose to be read-only and not to be modified according to Standard. And both have...
4
by: Simon Schaap | last post by:
Hello, I have encountered a strange problem and I hope you can help me to understand it. What I want to do is to pass an array of chars to a function that will split it up (on every location where...
37
by: jortizclaver | last post by:
Hi, I'm about to develop a new framework for my corporative applications and my first decision point is what kind of strings to use: std::string or classical C char*. Performance in my system...
10
by: william | last post by:
#include <stdio.h> int main() { char *str=NULL; char x="today is good!"; printf("%s", str); str=strtok(x," "); if (str=="today") //<==here is line that confuses me printf("they equals!\n");
8
by: Piotrek | last post by:
Hi, Like almost all of beginners I have problem understanding pointers. Please, look at this piece of code, and please explain me why myswap function doesn't work as it's supposed to do, whereas...
12
by: JackYee123 | last post by:
Hey, I need a structure to store a string array in c, for example Index Content -------- ----------- 0 word1 1 word2 2 3
2
by: LinLMa | last post by:
Hello everyone, I find strange result in the following program. 1. For string array, dereferencing it will result in the string itself, but for int array, dereferencing it will result in the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.