summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorrafa_99 <rafa99@protonmail.com>2020-11-22 14:23:05 +0000
committerrafa_99 <rafa99@protonmail.com>2020-11-22 14:23:05 +0000
commit7b644262f9ef0b5e5d5f5463b9cf96b78b67bfed (patch)
treec809ded185e51b46663c80d421d620738cc638cf /utils.c
parent596b63a8700e2953ce81b65f46a5b3015d45d904 (diff)
Fixed Problem With Line Size
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/utils.c b/utils.c
index c08990c..4a2b4ce 100644
--- a/utils.c
+++ b/utils.c
@@ -14,27 +14,25 @@ int lineCounter(FILE *dictionary)
int words = 0;
if ( dictionary != NULL )
{
- char line[256];
- while ( !feof(dictionary) )
+ char line[MAX_LINE];
+ for( words; (!feof(dictionary)); words++ )
{
- fgets(line, sizeof(line), dictionary);
- words++;
+ fgets(line, MAX_LINE, dictionary);
}
- words--;
rewind(dictionary);
+ words--;
}
-
return words;
}
char* getLine(FILE *dictionary, int lineNumber)
{
- char *line = (char *) calloc(256, sizeof(char));
+ char *line = (char *) calloc(MAX_LINE, sizeof(char));
if ( dictionary != NULL )
{
- for ( int i = 0; (!feof(dictionary) && i != lineNumber - 1); i++)
+ for ( int i = 0; (!feof(dictionary) && i != lineNumber ); i++)
{
- fgets(line, sizeof(line), dictionary);
+ fgets(line, MAX_LINE, dictionary);
}
rewind(dictionary);
}