It is well established law that the police do not need a warrant to search your car. However, they cannot search your car based upon mere suspicion or hunch. The police need what we in the legal field call "probable cause." Think of it like the police need to be able to articulate that there is a fair reason to believe that there is evidence of a crime in your car.
However, many would-be-defendants give the police permission to search their cars without demanding that the police have probable cause. When a police officer asks "do you mind if I search your car?" you do not need to say yes. Yet many will say yes, even when they have illegal contents in their car. By saying yes, you're setting yourself up for failure.
Furthermore, the police can only search those areas in which can contain the evidence they have probable cause for. In United States v. Ross, 456 U.S. 798, 824 (1982), the Supreme Court wrote:
"Probable cause to believe that a container placed in the trunk of a taxi contains contraband or evidence does not justify a search of the entire cab."
Think of it this way, let's say that the police have probable cause to believe that you are hiding an illegal firearm in the car. You cannot hide a firearm in the ash-tray. If the police open up the ash tray cover and discover a bag of heroin, the search is a no-go.
Oftentimes, defendants are their own worst enemies, because they don't understand their rights. Don't be one of those defendants when you're pulled over by the police.