Last week I found a simple game on the web called killallcops.exe. I studied the binaries and wondered why the programm is that big. (About 460k)
So I rewrote the game using iostream
#include <iostream>
int main(){
std::cout << "All cops are killed.\nCongratulations";
std::cin.ignore();
return 0;
}
compiled it with g++ and got 460k too.
I really wondered why this thing was so big and rewrote it using stdio
#include <stdio.h>
int main(){
printf("All cops are killed.\nCongratulations");
while(getchar() != '\n'){}
return 0;
}
compiled it with gcc and got 13k.
I know that iostream has much more abilities than stdio (like typesafety) and thus is itself much bigger, but why does this result in bigger binaries and are there solutions to reduce the size when using iostream, for example only using specific parts of it?
edit: as stated below using gcc 3.4.4 under cygwin