data type

Discussion in 'C Programming' started by aman, Oct 2, 2007.

  1. aman

    aman Guest

    is it true that c compiler automatically picks a variable as an
    integer if we can't explicitly declare it at beginning of a program????
     
    aman, Oct 2, 2007
    #1
    1. Advertising

  2. aman

    Ben Pfaff Guest

    aman <> writes:

    > is it true that c compiler automatically picks a variable as an
    > integer if we can't explicitly declare it at beginning of a program????


    No.
    --
    char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]
    ={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa67f6aaa,0xaa9aa9f6,0x11f6},*p
    =b,i=24;for(;p+=!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+
    2:{i++;if(i)break;else default:continue;if(0)case 1:putchar(a[i&15]);break;}}}
     
    Ben Pfaff, Oct 2, 2007
    #2
    1. Advertising

  3. aman

    jacob navia Guest

    aman wrote:
    > is it true that c compiler automatically picks a variable as an
    > integer if we can't explicitly declare it at beginning of a program????
    >


    Yes but you shouldn't use this feature. It is called "implicit int" and
    it is deprecated, i.e. it will be absent from view soon.

    You can write

    void function(arg)
    { return arg+5;}

    and it will work, but that is extremely bad practice.
    Good compilers will warn you about it.



    --
    jacob navia
    jacob at jacob point remcomp point fr
    logiciels/informatique
    http://www.cs.virginia.edu/~lcc-win32
     
    jacob navia, Oct 2, 2007
    #3
  4. aman

    Guest

    On Oct 2, 11:17 am, jacob navia <> wrote:
    > aman wrote:
    > > is it true that c compiler automatically picks a variable as an
    > > integer if we can't explicitly declare it at beginning of a program????

    >
    > Yes but you shouldn't use this feature. It is called "implicit int" and
    > it is deprecated, i.e. it will be absent from view soon.
    >

    No, this is NOT true in general.
    Consider:
    void foo(x) {
    y=x;
    }

    x will be implicitly assumed to be an int, but what about y?
    Are you trying to tell me that it will be implicitly assumed to be
    int?

    <snip>
    --
    Fred Kleinschmidt
     
    , Oct 2, 2007
    #4
  5. aman

    jacob navia Guest

    wrote:
    > On Oct 2, 11:17 am, jacob navia <> wrote:
    >> aman wrote:
    >>> is it true that c compiler automatically picks a variable as an
    >>> integer if we can't explicitly declare it at beginning of a program????

    >> Yes but you shouldn't use this feature. It is called "implicit int" and
    >> it is deprecated, i.e. it will be absent from view soon.
    >>

    > No, this is NOT true in general.
    > Consider:
    > void foo(x) {
    > y=x;
    > }
    >
    > x will be implicitly assumed to be an int, but what about y?
    > Are you trying to tell me that it will be implicitly assumed to be
    > int?
    >
    > <snip>
    > --
    > Fred Kleinschmidt
    >


    Of course is not true in general. Thanks for the correction.
    My post could have been misread to mean that.

    In C you declare always before you use it.

    --
    jacob navia
    jacob at jacob point remcomp point fr
    logiciels/informatique
    http://www.cs.virginia.edu/~lcc-win32
     
    jacob navia, Oct 2, 2007
    #5
  6. aman

    santosh Guest

    jacob navia wrote:

    > wrote:
    >> On Oct 2, 11:17 am, jacob navia <> wrote:
    >>> aman wrote:
    >>>> is it true that c compiler automatically picks a variable as an
    >>>> integer if we can't explicitly declare it at beginning of a program????
    >>> Yes but you shouldn't use this feature. It is called "implicit int" and
    >>> it is deprecated, i.e. it will be absent from view soon.
    >>>

    >> No, this is NOT true in general.
    >> Consider:
    >> void foo(x) {
    >> y=x;
    >> }
    >>
    >> x will be implicitly assumed to be an int, but what about y?
    >> Are you trying to tell me that it will be implicitly assumed to be
    >> int?
    >>
    >> <snip>


    > Of course is not true in general. Thanks for the correction.
    > My post could have been misread to mean that.
    >
    > In C you declare always before you use it.


    I think the OP probably got his impression from global objects which default
    to int when the type is not specified.
     
    santosh, Oct 2, 2007
    #6
  7. aman

    Tor Rustad Guest

    Ben Pfaff wrote:
    > aman <> writes:
    >
    >> is it true that c compiler automatically picks a variable as an
    >> integer if we can't explicitly declare it at beginning of a program????

    >
    > No.


    Agreed.

    In C, there is no need for the FORTRAN statement IMPLICITE NONE.

    --
    Tor <torust [at] online [dot] no>

    "Walking on water and developing software from a specification are easy
    if both are frozen"
     
    Tor Rustad, Oct 2, 2007
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. luna
    Replies:
    1
    Views:
    6,837
  2. heyo
    Replies:
    3
    Views:
    931
    Dan Pop
    Apr 1, 2004
  3. pete
    Replies:
    4
    Views:
    809
    Dan Pop
    Apr 2, 2004
  4. Yevgen Muntyan

    #define ALLOCIT(Type) ((Type*) malloc (sizeof (Type)))

    Yevgen Muntyan, Feb 9, 2007, in forum: C Programming
    Replies:
    10
    Views:
    920
    Yevgen Muntyan
    Feb 13, 2007
  5. kj
    Replies:
    5
    Views:
    418
Loading...

Share This Page