Find the answer to your Linux question:
Results 1 to 6 of 6
can nY1....??? tEll mE tht DATA TYPES in LINUX = 4 if nt understood : try 2 execute this .c programe in ur vi editor: step 1: open terminal step ...
  1. #1
    Just Joined! ajay2nokia's Avatar
    Join Date
    Jan 2008
    Location
    PUNE
    Posts
    4

    Thumbs up Data Types

    can nY1....??? tEll mE tht DATA TYPES in LINUX = 4
    if nt understood : try 2 execute this .c programe in ur vi editor:
    step 1: open terminal
    step 2: type vi followed by filename & give extension as .c. ex vi ppp.c
    step 3: type d matter as follows:
    step 4: #include<stdio.h>
    main ()
    {
    printf("Max size of Integer Data Type is %d",INT_MAX());
    }
    step 5: above program should execute bt dnt knw y its gettng executed whn
    printf statement is changes to :
    step 6: printf("Max size of integer Data Type is %d",size of (a);
    step 7: rest all remains d same if u execute by pressing esc & save by
    command :wq thn press enter
    step 8: u come 2 vi editor in tht type gcc ppp.c
    step 9: if u didnt get ny error its well nd good then final step 2 execute
    step 10: type ./a.out thn press enter


    plz ny1 ans me y it shows 4 in linux & 2 in windows ...!! thX In adv.....!!

  2. #2
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,316
    Hi and Welcome !

    I would suggest you to post in properly instead of using abbreviations. Its hard to understand what have written. English is not a native language of a lot of Members, including me.
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  3. #3
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    I would suggest you to post in properly instead of using abbreviations.
    Well said. There's more wrong with that post than just the English, but since we've been letting the poor chap twist slowly in the wind for six hours, it's time for a little mercy. :)

    A shred of a clue to what he wants is in his final line:
    plz ny1 ans me y it shows 4 in linux & 2 in windows ...!!
    Through the haze comes the awful truth: He's asking about sizeof(int).

    Well, ajay2nokia, type int is a two-byte integer on some C compilers and a four-byte integer on others, for historical reasons. If you want a type that's four bytes on most C compilers, I suggest you use long instead of int. If you want two byes, use short.

    Hope this helps. And please, next time, don't make us jump through all these linguistic hoops, ok?
    --
    Bill

    Old age and treachery will overcome youth and skill.

  4. #4
    Just Joined! ajay2nokia's Avatar
    Join Date
    Jan 2008
    Location
    PUNE
    Posts
    4
    yeah thX a lot 2 bOth..!! you are quite close 2 my Q....!!
    bUt my m@M asked me why int data types in linux is 4 where as int data type in win is 2....??? why...?? ThX

  5. #5
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    Please stop using abbreviations. It makes your questions very hard to understand. Just write out your English in full words, please.

    To answer your question: the int datatype was designed to be exactly one word, where a word is the amount of data that a CPU register can hold. Nowadays, many words are 32 bits (4 bytes), but in the past, words were 16 bits (2 bytes), and of course, with the coming of 64-bit processors, we are seeing words of 64 bits (8 bytes). However, because of the history of this datatype, ints can really hold any size. I believe that a C int is required to be at least 16 bits, but as far as I know, there is no other assurance except that a signed int can hold any value from INT_MIN to INT_MAX, and an unsigned int can hold any value from 0 to UNIT_MAX.
    DISTRO=Arch
    Registered Linux User #388732

  6. #6
    Just Joined! ajay2nokia's Avatar
    Join Date
    Jan 2008
    Location
    PUNE
    Posts
    4
    ThAnkX a LOT LINUX GURU.....!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...