Assume the market price is $100. Does the person with a limit buy at 1 cent get filled, or does the person with a market order get filled at a discount. Or is there some sort of safeguard? What would generally happen on an online broker.
Firstly, brokerages may have automated checks to stop this from happening. An extremely low price is a sign of a fat finger mistake, or an attempt at market manipulation.
Secondly, some stock markets forbid orders outside specific price ranges (e.g. relative to yesterday's opening/closing/high/low price). When trades breach these ranges, "circuit breakers" are triggered, and a trading halt is imposed. The details depend on the jurisdiction and specific stock market.
Stock exchanges must provide orderly markets to attract participants. Wild swings in prices caused by such 1 cent orders are not in their interest.
Since you didn't specify a country, this is a US centric answer:
National Best Bid and Offer (NBBO) is a Securities Exchange Commission (SEC) regulation requiring brokers to trade at the best available (lowest) ask price and the best available (highest) bid price when buying and selling securities for customers.
Any buy order at a price less than NBBO goes on the order book as a limit order at a lower price. The same holds true for a seller whose price is above NBBO.
During regular trading hours, you are not going to see a $100 stock with a NBBO bid of one cent. While bid-ask spreads widen during the after market, it is also improbable that you will see such a quote then as well.
However, if you hit the bid with a sell order (market price), you will get filled at that price unless your broker has a safeguard in place that prevents orders from being accepted that are "X" percent or "X" dollars away from the market. AFAIK, this is a user implemented feature rather than a broker safeguard. Having made a few fat fingered trades over the years, I recommend that you turn this on if your broker offers this feature.