Why are character arrays special (equal rights for structs)

Robert Forsman thoth at beach.cis.ufl.edu
Sun Feb 19 12:31:17 AEST 1989


  Excuse me, but I think my original topic has been corrupted (note I
fixed the subject line).  OK, I learned how to use an array on the
fly.

  if (intcmp(command,(int[]){GET,TORCH,0})==0) { ...

  Cool, but it isn't in ANSI (pat on the back to GNU though).  Now
here's one that I'm sure will blow your socks off.

{
  int a,b;

  scanf("%d %d",&a,&b);
  if (intcmp(command,(int[]){a,b,0})==0) { ...

  What a nifty new razorblade!  You have an array out in writeable
data space ready to accept any values and the code writes in a, b and
0 just before it needs them.  I'd like to see this added.  Really it
would just be a compression of

 {
  int a,b,goober[3];

  scanf("%d %d",&a,&b);
  goober[0] = a;
  goober[1] = b;
  goober[2] = 0;  /* should be unnecessary up above, since it's always 0 */
  if (intcmp(command,goober)==0) { ...

Anyone want to lobby to include it?


  As far as corrupting my topic goes, how did we get from array
declaration on the fly to token parsing (I only look at the subject
line when I'm junking a series of stupid postings or intelligent
questions outside my sphere of interest.)?  I'm curious.

/* of course it's my own opinion, did you see someone else post it? */
   Just say maybe to .signature



More information about the Comp.lang.c mailing list