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

  • Home
  • SEARCH
  • 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 8656083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:11:30+00:00 2026-06-12T15:11:30+00:00

I am using Code::Blocks and have set the command-line arugments via the IDE. I

  • 0

I am using Code::Blocks and have set the command-line arugments via the IDE. I have also opened the executable with the proper argument and I can’t manage to get a non-NULL on fopen() return. I’ve tried hard-coding the filename also with no success. The platform is Windows XP SP3.

The first is the one that fails, when i hardcoded it i used double backlash. Also i never knew if the second works because i never managed to start the process by opening the first one.

Obviously i put the text file in the same directory that the executable and rebuilt the executable many times, but it still doesn’t work.

EDIT: I added the perror(“fopen”); line in the if(finput==NULL) block. This is the output.

http://prntscr.com/h71pa

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

#define first_part_url "[url=http://magiccards.info/query?q="
#define second_part_url "&v=card&s=cname]"
#define end_bracket "[/url]\n"
#define output_file_prefix "output_"

char* get_card(FILE* finput);

int main(int n, char* arguments[])
{
FILE* finput;
FILE* foutput;
short int counter;
char* output_filename;
char* finalstring;


for(counter=1; counter<n; counter++)
{
    finput=fopen(arguments[counter], "r");

    if (finput==NULL)
    {
        printf("Unable to open ");
        puts(arguments[counter]);
                    perror("fopen");
        break;
    }

    strcpy(output_filename, output_file_prefix);
    strcat(output_filename, arguments[counter]);

    if((foutput=fopen(output_filename, "w"))==NULL)
    {
        printf("There was an error while trying to open ");
        puts(arguments[counter]);
        printf(" .\n");
        break;
    }

    while(!feof(finput))
    {
    finalstring=get_card(finput);
    fputs(finalstring, foutput);
    while(((fgetc(finput))!='\n')||feof(finput));
    }

    printf("Autocarding ");
    puts(arguments[counter]);
    printf(" was a success.\n");
    fclose(foutput);
}

if(finput!=NULL)
{
fclose(finput);
free(finalstring);
}
return 0;
}

char* get_card(FILE* finput)
{
char* currentcard;
char* finalstring;

currentcard=(char*)malloc(sizeof(char)*150);
fgets(currentcard, 150, finput);

/* Allocates the exact amount of space needed for the final string*/
finalstring=(char*)malloc(sizeof(char)*(strlen(first_part_url)+strlen(second_part_url)+strlen(end_bracket)+strlen(currentcard)));

/* Get all the final forum link together*/
strcat(finalstring, first_part_url);
strcat(finalstring, currentcard);
strcat(finalstring, second_part_url);
strcat(finalstring, end_bracket);

free(currentcard);

return finalstring;
}
  • 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-12T15:11:31+00:00Added an answer on June 12, 2026 at 3:11 pm

    The error you are getting, “No such file or directory” indicates that the file name you’re trying to open doesn’t exist.

    In this case, it’s probably because the program’s current working directory is not the same as the directory containing the executable file.

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

Sidebar

Related Questions

I have been using the gcc compiler with code::blocks ide, and have noticed there
I'm using Code::Blocks, and I have installed wxWidgets 2.8. Everything worked ok, I have
I'm using the Code::Blocks IDE with the GNU GCC compiler. struct test { char
We're developing a Qt project using the Code::Blocks IDE with the QtWorkbench plugin. We'd
I'm using Code::Blocks on Ubuntu 10.10 (Maverick Meerkat). I have connected a Mac keyboard
I am using the Mongo Ruby driver and have this block of Ruby code
I have the following block of jQuery code that I'm using to copy some
I am using codeblocks as my IDE. I have all the linker settings perfect,
I am using Code::Blocks 10.05, and the GNU GCC Compiler. Basically, I ran into
I'm using Code::Blocks to compile a shared library on Ubuntu. When I make a

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.