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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:04:34+00:00 2026-05-21T02:04:34+00:00

At the moment my program has no problem reading in a .txt file, but

  • 0

At the moment my program has no problem reading in a .txt file, but my program needs to read in a text file with a different file extension (.emu is the requirement). When simply changing the same file’s extension to .emu, the variable ‘file’ is NULL and therefore the file isn’t opened, can anyone help?

Had a little look around and haven’t been able to find a solution so any help is much appreciated

here’s the source code:

void handleArgs (const char *filename, int trace, int before, int after) {
FILE *file = fopen(filename, "r");
char *address = malloc(MAX_ADD_LENGTH * sizeof(char));
char *instruction = malloc(MAX_INS_LENGTH * sizeof(char));
long int addressDecoded;

if (file == NULL || file == 0) {
    fprintf(stderr, "Error: Could not open file");
}
else {
    if (ferror(file) == 0) {
        while (fscanf(file, "%s %s", address, instruction) != EOF) {
            if (strlen(address) == 8 && strlen(instruction) == 8) {
                addressDecoded = strtol(address, NULL, 16);
                printf("%ld\n", addressDecoded);
                //instruction = decodeInstruction(instruction);
            }
            else {
                fprintf(stderr, "Error: particular line is of wrong length");
            }

        }
    }
}

fclose(file);

}

argument ‘filename’ when executing is simply ‘/foopath/test.emu’

  • 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-05-21T02:04:34+00:00Added an answer on May 21, 2026 at 2:04 am

    There’s nothing special to C about the file extension. Reread your code for simple errors like changing the filename in one place, but not the other. If you’re passing in the filename, pass the whole name, not just the part to the left of the period.

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

Sidebar

Related Questions

For the moment my batch file look like this: myprogram.exe param1 The program starts
I have a program that needs several third-party libraries, and at the moment it
At the moment my code (PHP) has too many SQL queries in it. eg...
At the moment we use HSQLDB as an embedded database, but we search for
At the moment, I'm creating an XML file in Java and displaying it in
At the moment, our application uses the Trident Win32 component, but we want to
I'm maintaining a program that needs to parse out data that is present in
I'm really interested in speech-to-text algorithms, but I'm not sure where to start studying
I have a program that (amongst other things) has a command line interface that
I have a GUI problem that I would like to get sorted out, but

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.