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 9284311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:52:09+00:00 2026-06-18T18:52:09+00:00

I have two files with identical C code. I’m compiling one using Make and

  • 0

I have two files with identical C code. I’m compiling one using Make and one using GCC directly (gcc NAME.c -o NAME).

In the GCC-compiled program, all fprintf statements work fine. In the Make-compiled program, only the fprintf statements in the if statements work. The other ones don’t print anything. I haven’t been able to figure it why.

The code is:

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

#define BUFFER_SIZE 1000                 

int main(int argc, char ** argv) {       
    fprintf(stdout, "test\n");   
    if (argc != 2) {                     
        fprintf(stderr, "You must have one argument: filename or -h\n");
        return 1;
    }   

    if (strcmp(argv[1], "-h") == 0) {    
        fprintf(stdout, "HELP\n"); /*ADD TEXT HERE*/
    }   
    fprintf(stdout, "got to the end\n"); 
    return 0;                            
}

My makefile:

COMPILER = gcc
CCFLAGS = -ansi -pedantic -Wall

all: wordstat

debug:
    make DEBUG = TRUE

wordstat: wordstat.o
    $(COMPILER) $(CCFLAGS) -o wordstat wordstat.o
wordstat.o: wordstat.c
    $(COMPILER) $(CCFLAGS) wordstat.c

clean:
    rm -f wordstat *.o

The GCC one (run with -h) outputs:

changed text
HELP
got to the end

The Make one outputs:

HELP

Any help would be much appreciated.

  • 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-18T18:52:10+00:00Added an answer on June 18, 2026 at 6:52 pm

    You forgot the -c option in the makefile:

    .
    .
    .    
    wordstat.o: wordstat.c  
        $(COMPILER) $(CCFLAGS) -c wordstat.c
                                ↑ - important!
    

    Else this line doesn’t generate an object file but an executable elf file (a.out), and thus may lead to unexpected behavior because you recompile that to wordstat ( and it is already compiled).

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

Sidebar

Related Questions

I have two large identical-sized files. One is ASCII plain text, and the other
I have two functionally identical header files, one of which produces errors for no
I have discovered the following code appear in two identical .php files on more
I have two files with identical code (it is the code they mention here:
I have two files: SomeUserControl.en.ascx SomeUserControl.fr.ascx I'd like them to share the same code
I have two arrays. They seem to contain at least one identical set of
If you have two mainly identical files with 1000s of records, how will you
I have a program that takes two files as an argument. The first file
i have two FileInfo[] Array's and i want compare the Files with identical Names
I have two .csv files containing correlation matrices exported from R. One file contains

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.