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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:35:39+00:00 2026-06-15T22:35:39+00:00

i’m having a problem with a little C program i’m making. It’s working fine

  • 0

i’m having a problem with a little C program i’m making. It’s working fine when i compile it and run it on my mac (on a windows 7 partition) and on my work pc (windows 7 too) but i need it to work on a PC that is running a CNC and it is on windows XP. I can change the program location on the two computers, but it won’t work anywhere on the windows XP pc It seems to be crashing when it has to write a text file but it’s able to overwrite one … Is there some functions that aren’t compatible with windows XP ? I’ll try some more and i’ll let you know if i come across something.

P.S. can’t use the debugguer on this computer because i can’t install programs … (work computer).

Here’s the code that’s causing a problem :

int WritePrograms(int vitesse, double hauteur, int longueur, int largeur, double localRabotage, double localGroove, int overdrive)
    {
        char nameOfFile[75];
        char nomProgramR[75];
        char nomProgramG[75];
        char cheminDaccesR[100];
        char cheminDaccesG[100];
        char cheminDaccesGen[] = "programmes/";
        char genR[] = "_Rabotage.nc";
        char genG[] = "_Groove.nc";
        char confirmation [3];
        int i = 0;
        int c = 0;

        char *nomProgram = NULL;
        char *caractere = NULL;

        FILE* fichierRabotage = NULL;
        FILE* fichierGroove = NULL;

        do
        {
            memset(nomProgramG,0,sizeof(nomProgramG));
            memset(nomProgramR,0,sizeof(nomProgramR));
            memset(nameOfFile,0,sizeof(nameOfFile));
            memset(cheminDaccesG,0,sizeof(cheminDaccesG));
            memset(cheminDaccesR,0,sizeof(cheminDaccesR));
            do
            {
            printf("\nVeuillez choisir un nom pour votre programme : ");
            nomProgram = Saisie(nameOfFile,60);
            }while (nomProgram == "0");

            if (strcmp(nomProgram,"exit") == 0)
            {
                printf("\nVous avez decider de ne pas creer le programme\n\n");
                Sleep(2000);
                exit(0);
            }
            else if (strcmp(nomProgram,"\0") == 0)
            {
                printf("\nVous n'avez pas rentrer de nom pour votre programme\n");
                sprintf(nomProgramR,"%dX%.0fX%dX%d_Rabotage.nc",vitesse,hauteur*10000,longueur,largeur);
                sprintf(nomProgramG,"%dX%.0fX%dX%d_Groove.nc",vitesse,hauteur*10000,longueur,largeur);
                printf("\nUn nom generique lui a ete attribuer\n");
                sprintf(nomProgram,"%dX%.0fX%dX%d",vitesse,hauteur*10000,longueur,largeur);
                printf("\n%s\n",nomProgram);
                strcpy(cheminDaccesR,cheminDaccesGen);
                strcpy(cheminDaccesG,cheminDaccesGen);
                strcat(cheminDaccesR,nomProgramR);
                strcat(cheminDaccesG,nomProgramG);
            }
            else
            {
                strcpy(nomProgramG,nomProgram);
                strcpy(nomProgramR,nomProgram);
                strcpy(cheminDaccesR,cheminDaccesGen);
                strcpy(cheminDaccesG,cheminDaccesGen);
                strcat(nomProgramR,genR);
                strcat(nomProgramG,genG);
                strcat(cheminDaccesR,nomProgramR);
                strcat(cheminDaccesG,nomProgramG);
            }

            fichierRabotage = fopen(cheminDaccesR,"r");
            fichierGroove = fopen(cheminDaccesG,"r");
            if (fichierRabotage != NULL || fichierGroove != NULL)
            {
                do
                {
                printf("\nLe fichier existe deja, voulez-vous le remplacez (O/N)?");
                caractere = Saisie(confirmation,3);
                }while (strcmp(caractere,"O") != 0 && strcmp(caractere,"o") != 0 && strcmp(caractere,"n") != 0 && strcmp(caractere,"N") != 0);
                if (strcmp(caractere,"O") == 0 || strcmp(caractere,"o") == 0)
                {
                    c = 1;
                }
            }
            else
            {
                c = 1;
            }
        }while (c != 1);
        fclose(fichierGroove);
        fclose(fichierRabotage);

        fichierRabotage = fopen(cheminDaccesR,"w+");
        fichierGroove = fopen(cheminDaccesG,"w+");
        if (fichierRabotage != NULL && fichierGroove != NULL)
        {

        }
        else
        {
            printf("\nLe programmme n'as pas pu etre creer\n");
            Sleep(2000);
            exit(0);
        }
        fprintf(fichierGroove, "[OUTIL 3-CARBIDE 1/8-TEMPS: 7MIN] \n");
        fprintf(fichierGroove, "[MATERIEL-MOUSSE RPM 200]\n");
        fprintf(fichierGroove, "G20\nG00\nG90\nT2\nG53 Z\nG53 XY\nG92 Z%.4f\nG4 [Changer l'outil]\nM03\n",localGroove);
        fprintf(fichierGroove, "G0 X2.5\nG0 Y2.5\nG0 Z%.4f\n",hauteur);

        return 0;
    }

and here is headers.h as ask :

#ifndef HEADERS_H_INCLUDED
#define HEADERS_H_INCLUDED

char *Saisie(char *str,int n);
void viderBuffer();
int SaisieNombre(char *chaine,int a);
double SaisieNombreDecimal(char *chaine,int a);
double LireValeurCorrespondante(double thick);
int GetLocals(double *groove, double *rabotage);
int WritePrograms(int vitesse, double hauteur, int longueur, int largeur, double localRabotage, double localGroove, int overdrive);

#endif // HEADERS_H_INCLUDED
  • 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-15T22:35:40+00:00Added an answer on June 15, 2026 at 10:35 pm

    The problem here was that by opening two files to check if they existed and if one of them existed. the program would tell me if i wanted to overwrite it. I’d then close both files and overwrite them if needed but if they didn’t open, it would try to close a NULL pointer. So the solution was to do this :

    if (fichierGroove != NULL)
        {
        fclose(fichierGroove);
        }
        if (fichierRabotage != NULL)
        {
        fclose(fichierRabotage);
        }
    

    Lesson here : You can close a NULL pointer in windows 7 but not on XP

    Not sure for all other OSes.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I've tracked down a weird MySQL problem to the two different ways I was
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have been unable to fix a problem with Java Unicode and encoding. The
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

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.