While fighters are typically a martial class without spellcasting, the Eldritch Knight and Arcane Archer both gain access to at least one cantrip. There are many other ways to gain access to cantrips while playing a fighter.