Skip to content
Snippets Groups Projects
Commit 56d92122 authored by Skyx's avatar Skyx
Browse files

Bug fixes

parent b365f21a
No related branches found
No related tags found
No related merge requests found
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/app",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
\ No newline at end of file
7
Tes Tes
Test Test
Roro Roro
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
char ** Chargement(int *error, int *nbMots, char *nomFichier) char ** Chargement(int *error, int *nbMots, char *nomFichier)
{ {
FILE *f; FILE *f;
int i=0, nbChar; int i, nbChar;
char **mots=NULL; char **mots=NULL;
f=fopen(nomFichier,"r"); f=fopen(nomFichier,"r");
...@@ -25,15 +25,16 @@ char ** Chargement(int *error, int *nbMots, char *nomFichier) ...@@ -25,15 +25,16 @@ char ** Chargement(int *error, int *nbMots, char *nomFichier)
} }
else else
{ {
while(!feof(f)) fscanf(f, "%d\n", nbMots);
{ mots = (char**)malloc(sizeof(char*)*(*nbMots));
mots = (char **)realloc(mots, (i+1)*sizeof(char *));
if (!mots) if (!mots)
{ {
fprintf(stderr, "Problème d'allocation !\n"); fprintf(stderr, "Problème d'allocation !\n");
*error = EXIT_FAILURE; *error = EXIT_FAILURE;
} }
else { else {
for(i=0; i<*nbMots; ++i)
{
mots[i] = (char *)malloc(sizeof(char)*30); mots[i] = (char *)malloc(sizeof(char)*30);
if (!mots[i]) if (!mots[i])
{ {
...@@ -45,12 +46,10 @@ char ** Chargement(int *error, int *nbMots, char *nomFichier) ...@@ -45,12 +46,10 @@ char ** Chargement(int *error, int *nbMots, char *nomFichier)
nbChar = strlen(mots[i]); nbChar = strlen(mots[i]);
if(mots[i][nbChar-1] == '\n') if(mots[i][nbChar-1] == '\n')
mots[i][nbChar-1] = '\0'; mots[i][nbChar-1] = '\0';
++i;
} }
} }
} }
fclose(f); fclose(f);
*nbMots = i;
} }
return mots; return mots;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment