Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 2nd, 2006, 4:55 AM   #11
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,206
Rep Power: 5 grumpy is on a distinguished road
Technically, also;
char *x = "Hello";
is an anomoly of the C language, because this isn't allowed;
char *x = {'H', 'e', 'l', 'l', 'o', '\0'};
(which, if C was a perfectly consistent language) would be functionally equivalent. The treatment of string literals like this is a special case that was introduced into the language well before the C standard of 1989. The reason it was introduced was because of whinging programmers who wanted to be able to initialise a char pointer with a string.

The more general form (initialising a pointer with an array, as in the second case) was not added to the language DELIBERATELY (despite the anomoly of using string initialisers) because pointers and arrays are actually very different things, and it was considered desirable to keep them as separate things.
grumpy is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:20 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC