Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8868697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:19:37+00:00 2026-06-14T17:19:37+00:00

I have a very small C program which reverses a file. It compiles on

  • 0

I have a very small C program which reverses a file. It compiles on windows to an exe file of size 28,672 bytes.

  • What is the best approach for reducing the file size?
  • Are there any tools that can tell me what takes the most space? (included libraries)
  • Is this size normal for such a simple program?
  • What compiler flags should I use to reduce file size (/O1 and /Os doesn’t seem to make any effect)?

BTW – when compiled with gcc I get around 50Kb file and when compiled with cl I get 28Kb.

EDIT: Here is the code

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char *argv[])
{
   FILE *fi, *fo;

   char *file1, file2[1024];
   long i, length;
   int ch;

   file1 = argv[1];

   file2[0] = 0;
   strcat(file2, file1);
   strcat(file2, ".out");

   fo = fopen(file2,"wb");
   if( fo == NULL )
   {
      perror(file2);
      exit(EXIT_FAILURE);
   }

   fi = fopen(file1,"rb");
   if( fi == NULL )
   {
      fclose(fo);
      return 0;
   }

   fseek(fi, 0L, SEEK_END);
   length = ftell(fi);
   fseek(fi, 0L, SEEK_SET);

   i = 0;
   while( ( ch = fgetc(fi) ) != EOF ) {
      fseek(fo, length - (++i), SEEK_SET);
      fputc(ch,fo);
   }

   fclose(fi);
   fclose(fo);
   return 0;
}

UPDATE:

  • Compiling with /MD produced a 16Kb file.
  • Compiling with tcc (Tiny C Compiler) produced a 2Kb file.
  • Compiling with gcc -s -O2 produced a 8Kb file.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:19:38+00:00Added an answer on June 14, 2026 at 5:19 pm

    Try to compile it using tcc: http://bellard.org/tcc/ .

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very small program: public static void main(String[] args) { Queue<String> queue
I have to multiply a very small sized matrix ( size - 10x10 )
I have a very small batch script which is extracting a quite amount of
I have written a small test program in which I try to use the
I currently have a small Java program which I would like to run both
i have a very small utilty app written in c# that works fine on
I have a very small form where a user can enter their zip code
I have a very small office environment, and my team sends created pdfs to
I have vales with very small difference like... 0.000001. I want to visualize them
I have a requirement to change a very small part of the WPF ComboBox's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.