avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Bizarre string problem


From: Dave Hansen
Subject: Re: [avr-gcc-list] Bizarre string problem
Date: Thu, 09 Sep 2004 16:32:24 -0400

From: Richard Urwin <address@hidden>
[...]
Yes, I agree. It was the
   char t[1]="T"
I was questioning, since "T" is inherently 2 bytes long.

It might be standard C, or it may only be allowed on some compilers. I
don't have a copy of K&R to check.

FWIW, it is allowed by the standard. The relative passage is 6.7.8 (Initiailization) p14:

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.

The way I read this is

  char t[1] = "Thanks for all the fish.";

is legal and will initialize the first (and only) element of t to 'T'.

Regards,
  -=Dave

_________________________________________________________________
Is your PC infected? Get a FREE online computer virus scan from McAfee® Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963



reply via email to

[Prev in Thread] Current Thread [Next in Thread]