Originally Posted by
Shotgun
I have a few questions
Is bool.h ansi standard? as gcc compiler can't find it
Answer: No.
How do i malloc a matrix of [n] rows and [m] colums?
I know I have to use two nested loops but I don't understand how to do it thoe
Example:
Code:
int i;
int **matrix = malloc(NUMBER_OF_ROWS * sizeof(int));
for ( i = 0; i < NUMBER_OF_ROWS; ++i )
{
matrix[i] = malloc(NUMBER_OF_COLUMES * sizeof(int));
}
fgets reads all characters into a char array until it reaches an EOF or nl char, if it reaches a nl char it stores it.
Normaly char arrays I handle don't have nl chars in them, is this a problem?
I would prefer if all my char arrays were consistent and didn't have nl chars in them, how would I do this?
Do you treat your char arrays as strings? If so, how do you test for the end of string? If not, you could test your array for a nl (newline) and remove it. There's various ways...
fgets:
The fgets() function reads at most n-1 characters from stream into the buffer pointed to by s. No additional characters are read after fgets() has read and transferred a newline character to the buffer. A null character is written immediately after the last character that fgets() reads into the buffer.