Where did you found that code ?
If you look again, it probably has a getTemp() function that does a lot of OneWire magic to get the temperature out of the sensor.
but this time the voltage and temperature kept varying too much... i also tried your solution robtillart but i had to come out with the formula for the R... and this is doing the same in theory but in the loop
-1000 is the default 'error' temp it returns when it detects an invalid address, CRC error, etc. you'll have to play around and do some debugging to figure out exactly where the error is occurring. (I.e. Is it not finding the device, is it detecting an invalid address, etc)
Do you have it wired correctly with a pull up resistor?