Connect Cables in pc and it’s affect

Is there anyway I can know if the cable I use to charge my phone in it was connect to my pc before or not? Is there something in pc can let me see that because my pc contain some malware and spy files that comes to it through another phone because I used to use all cables and connect them to pc so I decided to format my other iphone in charger while charging it in the wall during deleting your data and setting the phone turned off so I connect it to the charger and it start to format and delete all data and settings while connect to charger so I format it again and I am afraid that the malware will be inside the iPhone system and even formatting it will no help