Removed getline (gosha gtfo!)

feature-fix-condition
germanFid 2022-10-24 10:42:00 +03:00
parent ceb9fa9c05
commit 63c107f7cb
2 changed files with 5 additions and 7 deletions

View File

@ -22,6 +22,7 @@
#define FALSE 0
// file
#define MAX_STRING_SIZE 1000
#define FILE_OPENING_ERROR "Cannot open the %s file.\n"
/// <summary>

View File

@ -3,11 +3,11 @@
int main(int argc, char **argv)
{
FILE *IFile = NULL;
char *ILine = NULL;
char ILine[MAX_STRING_SIZE + 1];
int16_t len = 0;
int32_t read;
char WRead[300];
char WRead[MAX_STRING_SIZE];
if (argc > 1)
{
@ -28,17 +28,14 @@ int main(int argc, char **argv)
exit(WRONG_ARGUMENT_FAILURE);
}
while ((read = getline(&ILine, &len, IFile)) != -1)
while ((read = fgets(&ILine, MAX_STRING_SIZE, IFile)) != NULL)
{
// printf("Retrieved line of length %zu:\n", read);
printf("%s", ILine);
parceLine(ILine);
}
printDataBase();
fclose(IFile);
if (ILine)
free(ILine);
exit(EXIT_SUCCESS); // Comment if you want continious reading after parsing file
} // if (argc > 1) -- correct