When i do a virus scan using AVG it says that my programs are viruses and doesn't let me open them, I'm using codeblocks and it says that the .exe file in debug/bin is a virus. Why is this? it even does it for "Hello World" programs.
some anti virus software have had the misfortune of being programmed into picking up cpp documents such as AVG i have no idea why they do this but they do it... i use norton on my windows/linux and they are better about this.
Shinigami most likely is the one that nailed it. I use AVG and have no issues with software or source code. The OP's PC is infected with an .exe-infecting virus, yielding infected exe's and AVG is picking them up.
If you're using Windows, I'd recommend Microsoft Security Essentials and Malwarebytes Anti-malware. MSE is great for live protection and MBAM is ideal for regular scans.
I would not recommend Microsoft Security Essentials. My friend had it and his computer was easily infected. When he sent a video online (youtube, skype video) wasn't able to use a computer. The processor was used 100%. Reinstalled antivirus to avira and it found a virus. Fixed problem and all good now.
Precaution can reduce the probability of virus, but can not avoid them. You can get virus even on this page if someone hacked it and puts a bad code.
When I used Windows (back in the 2000 to Windows Vista days), I never once used a passive anti-virus. I would run a monthly scan to find if anything is found sketchy and then allow me to take action. Out of the 7 years I used it (a mixture of AVG, Avira, and a few others I tried but didn't take advantage of passive scans), I never once found a virus.
I didn't use a passive AV on Windows and I don't care to use one on Linux.