i need to submit a program in 2 hours and im stuck.
i need to read a file and put it in a array so it can be used later and i got
Code:
void comando_read_file()
{
FILE *f;
int i;
char figuras[MAX_SIZE];
if ( ( f = fopen ("flatland.txt", "r" ) ) == NULL ) {
perror ( "error openning the file" );
exit ( 0 );
}
for ( i = 0; fgets ( figuras, MAX_SIZE, f ) != NULL; i++ ) {
figuras[i]=fputs(figuras, stdout);}
fclose (f);
}
also the program is about making circles and squares the file has this type of text:
NC 100 100 30 4
NS 300 300 40 40 3
....
NC - new circle
NR - new square
first 2 numbers are the centre points
the 30 is the raidius and 40 40 is the weith and lenght
4 and 3 is the color