The actual cost depends on your car mileage, number of people traveling in the car, type of motels/restaurant you intend to lodge in. However, you one can get close enough estimates based on average for the following: Medium sized car in pretty good shape, no passengers other than the driver, moderate quality motel, fast food restaurants.
The driving distance between NYC and SF is just over 2,900 miles. Assuming you intend to spend 9 hours each day on the rood, out of which you should deduct 2 hours for food, rests, gas etc. That leaves about 7 hours of driving. At an average speed of 60 MPH, you should average 60*7= 420 miles every day. 2,900/420 = 6.9 days. Allowing for unpredictable stoppages etc, say 7 days.
Motels: 6 nights @ $60 = $360
Food 7 days @ $40/person = $280
Gas 2900 miles/24 mpg = 121 gallons @ say $3 = $363
Miscellaneous; $15 per day x 7 days = $105.
Total approximate cost = $360 + $280 + $363 + $105 = $ 1,108
Not allowing for breakdown or unforeseen, $1,200 should be a fair estimate of the cost of the trip.
Here are the driving directions and miles breakdown for that trip:
Hope this helps.