@Manikanta: What compiler do you use?

================================================
$ gcc test.c
test.c:2: error: initializer element is not constant

$ g++ test.c
$ ./a.out
Hello

$ gcc --version
gcc (GCC) 4.1.1
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
================================================

g++ treats the source code as C++.


On 2011-3-18 13:34, Manikanta Babu wrote:
@Dondod is right.
It works perfectly. Because printf returns the number of characters printed so n will be initialized with the number of characters. You can try out this simple program. I checked its working perfectly.
Thanks,
Mani
On Fri, Mar 18, 2011 at 9:59 AM, .bashrc <[email protected] <mailto:[email protected]>> wrote:

    @Don.Its illegal in c(Or in c99) to initialize a variable with
    anything other than a constant.
    @pacific No c structures do not support constructor(Or destructor)

    On Mar 18, 9:08 am, pacific pacific <[email protected]
    <mailto:[email protected]>> wrote:
    > Does  C struct have constructor ?
    >
    >
    >
    > On Fri, Mar 18, 2011 at 12:55 AM, Don <[email protected]
    <mailto:[email protected]>> wrote:
    > > int n = printf("Hello\n");
    >
    > > int main()
    > > {
    >
    > > }
    >
    > > On Mar 17, 8:08 am, himanshu kansal
    <[email protected] <mailto:[email protected]>>
    > > wrote:
    > > > is there any way to print hello in c also wdout writing
    anythng in
    > > > main()....
    >
    > > > On Thu, Mar 17, 2011 at 6:34 PM, kunal srivastav <
    > > [email protected] <mailto:[email protected]>
    >
    > > > > wrote:
    > > > > noooo...c does not support classes
    >
    > > > > On Thu, Mar 17, 2011 at 6:10 PM, himanshu kansal <
    > > > > [email protected]
    <mailto:[email protected]>> wrote:
    >
    > > > >> is this possible in c also????
    >
    > > > >> On Wed, Mar 16, 2011 at 11:57 PM, Manikanta <
    > > [email protected]
    <mailto:[email protected]>>wrote:
    >
    > > > >>> Thats right in C++. How about in C.
    >
    > > > >>> On Mar 16, 9:44 pm, kumar anurag
    <[email protected] <mailto:[email protected]>> wrote:
    > > > >>> > @anurag good.....
    > > > >>> > On Wed, Mar 16, 2011 at 9:28 PM, Anurag atri <
    > > [email protected] <mailto:[email protected]>
    > > > >>> >wrote:
    >
    > > > >>> > > #include<iostream>
    > > > >>> > > using namespace std ;
    > > > >>> > > class a
    > > > >>> > > {
    > > > >>> > >         public :
    > > > >>> > >         a() { cout<<"hello";}
    > > > >>> > > }a1;
    > > > >>> > > int main()
    > > > >>> > > {
    > > > >>> > > }
    >
    > > > >>> > > On Wed, Mar 16, 2011 at 8:25 PM, himanshu kansal <
    > > > >>> > > [email protected]
    <mailto:[email protected]>> wrote:
    >
    > > > >>> > >> How can u print "hello" in a c/c++ program without
    writing a
    > > single
    > > > >>> > >> word in main() function....
    >
    > > > >>> > >> --
    > > > >>> > >> You received this message because you are
    subscribed to the
    > > Google
    > > > >>> Groups
    > > > >>> > >> "Algorithm Geeks" group.
    > > > >>> > >> To post to this group, send email to
    [email protected] <mailto:[email protected]>
    > > .
    > > > >>> > >> To unsubscribe from this group, send email to
    > > > >>> > >> [email protected]
    <mailto:algogeeks%[email protected]>.
    > > > >>> > >> For more options, visit this group at
    > > > >>> > >>http://groups.google.com/group/algogeeks?hl=en.
    >
    > > > >>> > > --
    > > > >>> > > Regards
    > > > >>> > > Anurag Atri
    >
    > > > >>> > > --
    > > > >>> > > You received this message because you are subscribed
    to the
    > > Google
    > > > >>> Groups
    > > > >>> > > "Algorithm Geeks" group.
    > > > >>> > > To post to this group, send email to
    [email protected] <mailto:[email protected]>.
    > > > >>> > > To unsubscribe from this group, send email to
    > > > >>> > > [email protected]
    <mailto:algogeeks%[email protected]>.
    > > > >>> > > For more options, visit this group at
    > > > >>> > >http://groups.google.com/group/algogeeks?hl=en.
    >
    > > > >>> > --
    > > > >>> > Kumar Anurag- Hide quoted text -
    >
    > > > >>> > - Show quoted text -
    >
    > > > >>> --
    > > > >>> You received this message because you are subscribed to
    the Google
    > > Groups
    > > > >>> "Algorithm Geeks" group.
    > > > >>> To post to this group, send email to
    [email protected] <mailto:[email protected]>.
    > > > >>> To unsubscribe from this group, send email to
    > > > >>> [email protected]
    <mailto:algogeeks%[email protected]>.
    > > > >>> For more options, visit this group at
    > > > >>>http://groups.google.com/group/algogeeks?hl=en.
    >
    > > > >>  --
    > > > >> You received this message because you are subscribed to
    the Google
    > > Groups
    > > > >> "Algorithm Geeks" group.
    > > > >> To post to this group, send email to
    [email protected] <mailto:[email protected]>.
    > > > >> To unsubscribe from this group, send email to
    > > > >> [email protected]
    <mailto:algogeeks%[email protected]>.
    > > > >> For more options, visit this group at
    > > > >>http://groups.google.com/group/algogeeks?hl=en.
    >
    > > > > --
    > > > > thezeitgeistmovement.com <http://thezeitgeistmovement.com/>
    >
    > > > > --
    > > > > You received this message because you are subscribed to
    the Google
    > > Groups
    > > > > "Algorithm Geeks" group.
    > > > > To post to this group, send email to
    [email protected] <mailto:[email protected]>.
    > > > > To unsubscribe from this group, send email to
    > > > > [email protected]
    <mailto:algogeeks%[email protected]>.
    > > > > For more options, visit this group at
    > > > >http://groups.google.com/group/algogeeks?hl=en.
    >
    > > --
    > > You received this message because you are subscribed to the
    Google Groups
    > > "Algorithm Geeks" group.
    > > To post to this group, send email to
    [email protected] <mailto:[email protected]>.
    > > To unsubscribe from this group, send email to
    > > [email protected]
    <mailto:algogeeks%[email protected]>.
    > > For more options, visit this group at
    > >http://groups.google.com/group/algogeeks?hl=en.
    >
    > --
    > regards,
    > chinna.

    --
    You received this message because you are subscribed to the Google
    Groups "Algorithm Geeks" group.
    To post to this group, send email to [email protected]
    <mailto:[email protected]>.
    To unsubscribe from this group, send email to
    [email protected]
    <mailto:algogeeks%[email protected]>.
    For more options, visit this group at
    http://groups.google.com/group/algogeeks?hl=en.




--
Thanks & Regards,
Mani
http://www.sanidapa.com - The music Search engine
--
You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.

--
You received this message because you are subscribed to the Google Groups "Algorithm 
Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to