hoe to allocate a 2 dimensions array?

hi .

how can I allocate a 2 dimensions array?

I used :

{
int i;

/* Allocating the rows */
Schedule = \(int **\)\( malloc\( sizeof\(int*\) * \(N-2\) \) \);
if\( Schedule == NULL \)
\{
	printf\("\\nError - couldn't allocate memory! Aborting...\\n"\);
	exit\(-1\);
\}
/* Allocating memory for columns */
for\( i = 0; i < N - 1; i\+\+ \)
\{
	Schedule [i]= \(int *\)\( malloc\( sizeof\(int\) * N \) \);
	if\( Schedule [i]== NULL \)
	\{
		printf\("\\nError - couldn't allocate memory! Aborting...\\n"\);
		exit\(-1\);
	\}
\}
return;

}

end of quote!

but it doesn't allocate the array .... when I use : "Schedule[0][0] = 1;" , for example , I get "segmetation fault" .

Thanks , Azran .

You are thinking that arrays and pointers are interchangable. They are not. Read this section of the c faq. Your question is addressed in question 6.16, but you should read the entire section.

The Schedule[i][j] is a pointer.
Your allocate program is right. But you are trying to change the value of a pointer Schedule[0][0]. You may just want to change the value it points to, if you do, you coulde use:
*Schedule[0][0] = 1