Ticket offices at Chamartin Railway station are always quite busy, so you can expect to spend aproximately one hour until you have your ticket.
For in-advanced-reservations or international railway tickets, you must pick up a number, and then wait your turn. At least, this has the advantage that you can go and sit or use the time to do something.
For same-day trains, there's no number, so you must have patience and queue at one of the ticket offices which has the sign "trenes para hoy" or something similar (trains for the same day).
In the Spring of 1981, after my sister's wedding, my cousin and I departed from the Charmartin train station to go to Paris. Little did I know that within a year I would be living in Madrid in the neighborhood named after this station.
As to the look on my face I believe this can be attributed to being young and stupid and impatient for some good times to start.
Chamartin station is located in the Northern suburbs and is reachable my metro. It is a lot less grand than Atocha, and offers local and medium distance service. Be sure to arrive early to buy tickets. You may check timetables at www.renfe.es.
On weekends, I would make use of my Eurailpass by leaving from Chamartín station for Lisbon and Barcelona. On one occasion, I was there for longer than planned. If all had gone according to planned, I would have arrived there in plenty of time to get the metro back to the Moncloa station for a short walk to the dorm. However, on the way back from Barcelona on 22 July 1990, we were behind a train derailment near Zaragoza. That delayed us for hours. It was so significant that the conductors passed around churros, juice and those hot towels you get on foreign flights. On finally arriving back to Madrid, the metros had closed and wouldn't resume operation until 6 am. When I tried to sleep on the floor, some RENFE employee told me I couldn't sleep there. I just said, "I'm sorry, I don't speak a word of Spanish."
I took overnight train from Madrid Chamartin Railway station to Lisbon for EUR 72 (Nov 2004). It was a sleeper in a cabin for 4 pax. The bed is narrow and small, but comfortable. The train left at 10 pm and arrived Lisbon around 7 am. There is not much difference between the sleeper and seat (EUR 54).
There is a train station in Madrid (Chamartin), so you can take the train to get there from most places in Spain. A train ride between Salamanca and Madrid is a few hours. Although you can buy a ticket the day of your trip, it's better to book in advance because in the summer, the train is often full.
Chamartin is the railway station for trains going NORTH and EAST of Spain (Barcelona, Bilbao, San Sebastián, Paris, Burgos...).