Click here to Skip to main content
15,914,013 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: C is a better language than any language you care to name. Pin
W Balboos, GHB29-May-14 9:07
W Balboos, GHB29-May-14 9:07 
GeneralRe: C is a better language than any language you care to name. Pin
Joe Woodbury29-May-14 9:40
professionalJoe Woodbury29-May-14 9:40 
GeneralRe: C is a better language than any language you care to name. Pin
Nemanja Trifunovic29-May-14 9:59
Nemanja Trifunovic29-May-14 9:59 
GeneralRe: C is a better language than any language you care to name. Pin
Joe Woodbury29-May-14 10:07
professionalJoe Woodbury29-May-14 10:07 
GeneralRe: C is a better language than any language you care to name. Pin
Joe Woodbury29-May-14 10:47
professionalJoe Woodbury29-May-14 10:47 
GeneralRe: C is a better language than any language you care to name. Pin
Jeremy Falcon29-May-14 11:01
professionalJeremy Falcon29-May-14 11:01 
GeneralRe: C is a better language than any language you care to name. Pin
Nemanja Trifunovic29-May-14 12:35
Nemanja Trifunovic29-May-14 12:35 
GeneralRe: C is a better language than any language you care to name. Pin
Joe Woodbury29-May-14 12:56
professionalJoe Woodbury29-May-14 12:56 
Nemanja Trifunovic wrote:
char *p = "hello"; //pointer - no information about the dimension
char q[] = "hello"; // array - contains information about the dimension


No the ARRAY does not. The declaration does and thus the precompiler) and sizeof(), but not the array itself.

To illustrate, the function:

void _function(const char r[])
{
   printf("%u\n", sizeof(r));
}
Will print 4 or 8, depending on the size of a pointer, when you call _function(q);.

Added: Moreover, an optimizing compiler will likely pool both strings and use the same pointer for both operations (especially since it's clear they are both const.) Again, the sizeof() is handled by the precompiler, not at runtime.

modified 29-May-14 19:06pm.

GeneralRe: C is a better language than any language you care to name. Pin
jschell30-May-14 13:31
jschell30-May-14 13:31 
GeneralRe: C is a better language than any language you care to name. Pin
Joe Woodbury30-May-14 13:53
professionalJoe Woodbury30-May-14 13:53 
GeneralRe: C is a better language than any language you care to name. Pin
jschell2-Jun-14 9:03
jschell2-Jun-14 9:03 
GeneralRe: C is a better language than any language you care to name. Pin
PIEBALDconsult30-May-14 19:39
mvePIEBALDconsult30-May-14 19:39 
GeneralRe: C is a better language than any language you care to name. Pin
jschell2-Jun-14 9:13
jschell2-Jun-14 9:13 
GeneralRe: C is a better language than any language you care to name. Pin
PIEBALDconsult30-May-14 16:42
mvePIEBALDconsult30-May-14 16:42 
GeneralRe: C is a better language than any language you care to name. Pin
dandy7229-May-14 10:14
dandy7229-May-14 10:14 
GeneralRe: C is a better language than any language you care to name. Pin
Ernst Iliov Stavro Blofeld29-May-14 10:46
Ernst Iliov Stavro Blofeld29-May-14 10:46 
GeneralRe: C is a better language than any language you care to name. Pin
  Forogar  29-May-14 12:15
professional  Forogar  29-May-14 12:15 
GeneralRe: C is a better language than any language you care to name. Pin
Member 419459329-May-14 13:27
Member 419459329-May-14 13:27 
JokeRe: C is a better language than any language you care to name. Pin
Karen Mitchelle29-May-14 15:46
professionalKaren Mitchelle29-May-14 15:46 
RantRe: C is a better language than any language you care to name. Pin
Vivi Chellappa29-May-14 19:18
professionalVivi Chellappa29-May-14 19:18 
GeneralRe: C is a better language than any language you care to name. Pin
PIEBALDconsult29-May-14 19:23
mvePIEBALDconsult29-May-14 19:23 
JokeRe: C is a better language than any language you care to name. Pin
Rutvik Dave29-May-14 19:59
professionalRutvik Dave29-May-14 19:59 
GeneralRe: C is a better language than any language you care to name. Pin
Roger Wright29-May-14 20:36
professionalRoger Wright29-May-14 20:36 
GeneralRe: C is a better language than any language you care to name. Pin
Rutvik Dave30-May-14 0:08
professionalRutvik Dave30-May-14 0:08 
JokeRe: C is a better language than any language you care to name. Pin
Peter Adam29-May-14 21:07
professionalPeter Adam29-May-14 21:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.