The king was speaking on a visit to the dozens of hospitalized survivors in Santiago de Compostela, near to where the train derailed on Wednesday night.
Prime Minister Mariano Rajoy, who hails from the city of the crash, declared three days of official mourning on Thursday.
One of the train drivers is under formal investigation, officials say.
The driver, named by Spanish media as Francisco Jose Garzon Amo, was slightly injured and will be questioned by police in hospital, the Galicia Supreme Court said in a statement.
Spain’s national train operator Renfe said it was too early to say what caused the train to derail. However, survivor accounts and media reports suggest the train was travelling at excessive speed as it hit a curve in the track.
Footage captured by a security camera shows the train crashing as it hurtled round a bend.
King Juan Carlos and his wife Queen Sofia visited survivors and the families of victims at Santiago’s University Hospital on Thursday.
“All Spanish people join in the sorrow of the relatives of the deceased,” he said, praising what he called the spirit of citizenship shown by rescue workers and blood donors.
PM Mariano Rajoy was at the scene of the crash on Thursday.
“For a native of Santiago like me, this is the saddest day,” he said.
At least 130 people were taken to hospital after the crash, and 94 are still being treated, health officials say.
Thirty-two people are seriously injured, including children.
People from several nationalities are among the wounded, including five Americans and one Briton. One American was among the dead.
The Madrid to Ferrol train’s data recording “black box” is now with the judge in charge of the investigation.
Meanwhile, the train’s carriages have been removed from the track by cranes and sent for analysis.
The president of railway firm Renfe, Julio Gomez Pomar, was quoted by El Mundo newspaper as saying the driver, who was aged 52, had 30 years of experience with the company and had been operating trains on this line for more than a year.
He said the train which derailed had no technical problems.
“The train had passed an inspection that same morning. Those trains are inspected every 7,500km… Its maintenance record was perfect,” he told Spanish radio.
But Francisco Jose Garzon Amo, who was trapped in the cab after the accident, is quoted as saying moments after the crash that the train had taken the curve at 190 km/h (120mph) despite a speed limit on that section of 80 km/h.
If this is the case, it remains to be seen whether a systems failure or driver error was the cause, correspondents say.
Spain has invested huge amounts of money in its rail network and has a relatively good safety record.
According to official figures, the crash is one of the worst rail disasters in Spanish history.
Renfe said the train came off the tracks a few kilometres before Santiago de Compostela station at 20:41 local time on Wednesday.
It was on the express route between the capital, Madrid, and the port city of Ferrol on the Galician coast, with 218 passengers on board – in addition to an unknown number of staff and crew.
Witnesses to the crash described seeing carriages “piled on top of one another” after the train hit a curve.
The derailment happened on the eve of Santiago de Compostela’s main annual festival where thousands of Christian pilgrims were expected to flock to the city in honor of St James.
The local tourism board cancelled all festivities as the city went into mourning.
91kT4V1gsX0Image source: Wikimedia Commons President-elect Donald Trump celebrated his election victory at the Ultimate Fighting…
Millions of voters across the US chose to return Donald Trump to the White House…
Donald Trump declares victory in the US election as he addresses jubilant supporters in Florida.…
Stocks around the world are rising as Donald Trump appears to be on the cusp…
Donald Trump has won Pennsylvania, North Carolina and Georgia and taken a lead over Kamala…
Quincy Jones, the celebrated musician and producer who worked with Michael Jackson, Frank Sinatra, Ray…