Mates, this is my first piece of C code. I do not know what is wrong. Please, tell me, that's not so I've highlighted the lines that the compiler "doesn't like " -

#include <stdio.h>
#include <alloc.h>
#include <stdlib.h>
  main()
{ short int n = 0;
  int k=0,u,i=0;
  char a='';
  short int **m ; 
  

  printf("\nPlease specify the dimension of the matrix. \n");
  n = getchar();
  printf("Specify values of elements of the matrix (figures)separated by spaces. \n");
  m = (int**)calloc(n,sizeof(int*));
  For(i=1;i<=n;i++)
  {*(m+i) = (int*)calloc(n,sizeof(int));}
  while (i<(n*n))
  { 
    u = getchar();  
    if ((u != ' ')&&(u != '\n'))
	{
	  i = i+1;
	  *(*(m+i)+k)=u;
	  if (i==n) {i=0; k++;}
	}
  }
  if (i<=(n*n)) then  printf("\n (!)ERROR: Dimension of the matrix exceeds the number of specified values. \n");
  
}

Thank you for your help! ))

You need to allocate the outer pointer first, than the sizes of the inner pointers.

On 'For' it should be 'for'.

main() should be an 'int' and successfully return zero on completion.

You need to allocate the outer pointer first, than the sizes of the inner pointers.

On 'For' it should be 'for'.

main() should be an 'int' and successfully return zero on completion.

Thank you, MosaicFuneral ))
I will deal with this)

do you think that i should do it in this order -

For(i=1;i<=n;i++)
  {*(m+i) = (int*)calloc(n,sizeof(int));}
  m = (int**)calloc(n,sizeof(int*));

I can understand - what is wrong with the "main".......help, please........

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.