dimanche 21 août 2016

Assigning value of variable through pointer [duplicate]

This question already has an answer here:

Why the output of x in the programming is 0 instead of 1/2?

#include <stdio.h>
#include <stdlib.h>

int main()
{   
        double *xp,x;
        xp = &x;
        *xp = 1/2;
        printf("%fn",x);
        return 0;
}

give the result of

0.000000

Aucun commentaire:

Enregistrer un commentaire