<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Declaring Strings' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Declaring Strings' posted on the 'C and C++' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Sun, 26 May 2013 00:38:30 -0700</pubDate>
    <lastBuildDate>Sun, 26 May 2013 00:38:30 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Declaring Strings</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/423666/423666/declaring-strings/</link>
      <description>I can write char a[] = "hello world"; , but i can not write&lt;br /&gt;
char a[];&lt;br /&gt;
a = "hello world";&lt;br /&gt;
why so?&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/423666/423666/declaring-strings/</guid>
      <pubDate>Fri, 06 May 2011 02:23:37 -0700</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Re: Declaring Strings</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/423666/423669/re-declaring-strings/#423669</link>
      <description>char a[] = "hello world";&lt;br /&gt;
&lt;br /&gt;
you can that because the compiler knows how much space to allocate for the string "hello world."&lt;br /&gt;
&lt;br /&gt;
char a[];&lt;br /&gt;
a = "hello world";&lt;br /&gt;
&lt;br /&gt;
C won't allow aggregate assignment; you've got an array of chars and a string, which aren't exactly the same thing.  you've also got an unknown size - the compiler doesn't know much space to allocate to a.&lt;br /&gt;
&lt;br /&gt;
char a[80];&lt;br /&gt;
strcpy(a, "hello world");&lt;br /&gt;
&lt;br /&gt;
An interesting feature of C though is you can assign structs.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
typedef struct {
   char a[40];
} test;

test t1 = { "hello world" }, t2 = t1;

puts(t1.a);
puts(t2.a);
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
HTH&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/423666/423669/re-declaring-strings/#423669</guid>
      <pubDate>Fri, 06 May 2011 10:30:26 -0700</pubDate>
      <category>C and C++</category>
    </item>
  </channel>
</rss>