Hello, I'm new to C and I'm not sure what is wrong with my code here.
After I execute, I get this:
Debug assertion failed!
[program address]
File: fgets.c
Line: 60
Expression: str != NULL
It's a really simple program. I'm trying to assign family data from the in file to the out file with formatting (things commented out), but this is just the start of that program but I can't finish it out since I ran into this problem.
I searched the forum first but this same error is either unsolved in C, or in C++. Or the situation is different because the code is more complicated.
Anyway, here's my full code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void main (void)
{
FILE *in, *out;
char people[81];
int number;
printf("This program reads in from familyin.txt, formats its data,\n and writes it out to familyout.txt.");
in = fopen ("c: \\familyin.txt", "r");
out = fopen ("c:\\familyout.txt", "w");
fgets (people, 80, in);
number = atoi(people);
printf("The text from familyin.txt is \n %s \n", people);
printf("The numberic value is %i. \n\n", number);
fprintf(out, "The text from familyin.txt is \n %s \n", people);
/*familyin = fopen (
// struct family {
// char name [50]; /* person's name */
// char street [50]; /* street address */
// char csz [50]; /* city, state, zip */
// char relation [30]; /* relation to you */
//// char birthday [11]; /* mm-dd-yyyy */
// };
// struct family people[7];
fclose (in);
fclose (out);
}