LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Doubts in c (https://www.linuxquestions.org/questions/programming-9/doubts-in-c-330123/)

rajesh_b 06-03-2005 08:33 PM

Doubts in c
 
Hi,

I have came across these following questions in some website. But i dont know the answers for those... Actually these are the interview questions asked in sun microsystems.

The questions are

1.How do you know my machine(CPU) is 64 bit or 32 bit
without use of sizeof oerator?



2. What do u mean by malloc(***)?



3. How can we know whether kernel has support for threading?


Can any body tell me what are the answers for those?

Thankx in advance,
Rajesh.

MoneyCat 06-03-2005 10:32 PM

Quote:

1. How do you know my machine(CPU) is 64 bit or 32 bit without use of sizeof oerator?
Code:

#include <stdio.h>

int main()
{
    char *c = (char*)0x100000000;      // 4Gb
    c++;

    if(&*c > 0)
        printf("machine is 64bit\n");
    else
        printf("machine is 32bit\n");

    return 0;
}

Quote:

2. What do u mean by malloc(***)?
The syntax does not seem to conform to the ANSI/ISO Standard C.



Good luck :)

rajesh_b 06-06-2005 09:54 PM

Can u explain the code
 
Hi MoneyCat,

Thanx for ur reply.
Even though i m getting little warnings, the program is working fine. But i am not able to understand the code. Can u please explain the code little bit. Waiting for ur reply.



Rajesh.


All times are GMT -5. The time now is 01:29 AM.