lines: add null check after opening infile
This commit is contained in:
@@ -21,6 +21,11 @@
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
FILE* infile = fopen("lines.txt", "r");
|
FILE* infile = fopen("lines.txt", "r");
|
||||||
|
if (infile == NULL)
|
||||||
|
{
|
||||||
|
perror("Failed to open in.txt");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
char buf[SIZE];
|
char buf[SIZE];
|
||||||
|
|
||||||
while (fgets(buf, sizeof buf, infile) != NULL)
|
while (fgets(buf, sizeof buf, infile) != NULL)
|
||||||
|
|||||||
Reference in New Issue
Block a user