From: j DOT aldrich6 AT genie DOT com Message-Id: <199605302018.AA238477516@relay1.geis.com> Date: Thu, 30 May 96 20:03:00 UTC 0000 To: djgpp AT delorie DOT com Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Subject: Re: Moving from Pascal to Djgp Reply to message 2169667 from RKWCVDZ AT RIVIE on 05/30/96 3:25AM >[1] File Bloat . Why are the Files Compiled with Djgpp so Bloated . The > Standard Hello world program compiled with Gcc -o Hello.exe Hello.c was > nearly 58k ,and if i used Gcc -s -o Hello.exe hello.c it came down to > 20k.In comparison the same Program in Borland Pascal 7.0 Real mode is > 2.9kb and 8,2kb for Protected mode (with the stub included). Whats the > most effecient way to Compile Small Programs.Also a C++ version is even > more bloated why ? Others have already posted good replies to this question, but I would also add that the correct functions to define away if you don't need them are the following: char **__crt0_glob_function( char *_argument ) { return 0; } void __crt0_load_environment_file( char *_app_name ) { return; } void __crt0_setup_arguments( void ) { return; } If you don't need the functionality provided by these functions, simply definethem away in the manner above, and the size of your executable will be substantially reduced. >[2] Can someone tell me what is wrong with the Following Program fragment > #include > > int main(void); > void exit(int); You don't need to declare main and exit. main should be the first function in your program, and unless it is recursive nobody else should be calling it. exit() is declared in . > int main(void) >{ > int c; > File *fin, *fout; As mentioned by somebody else, it's not File, it's FILE. I believe that the lowercase name is also valid (it's simply #defined to FILE), but using it is not a good habit to get into. > fin = fopen("in.dat", "r"); > if (fin == NULL) { > printf("Unable to open file in.dat\n"); > exit(1); > } > > fout = fopen("out.dat", "w"); > if (fout == NULL) { > printf("unable to open file out.dat\n"); > exit(2); > } You could try merging the fopen and if statements into one line, forelegance, i.e. if ( ( fout = fopen( "out.dat", "w" ) ) == NULL ) Also, I hate it when people line braces up (or rather, don't line them up) like that, but I suppose it's so deeply ingrained into the C culture that there's no erasing it. :) > while ((c=fgetc(fin)) != EOF) { > if (fputc(c, fout) != c) { > printf("Error writing out.dat\n"); > exit(3); > } > } >fclose(fin); >fclose(fout); >return 0; >} > >Why doesnt this Program Compile ... I get errors while compiling it. ? >Is the above Program Structurally correct ? It seems to be as far as I can tell. But please post the errors you get. How can we help you without that information?? John