c - How to initialize, create matrix and then print with using structure -


I want to create a 2D head using the structure and read it from the user, then display it. But I do not know what is wrong with it. / People Sorry. First of all, I want to read a matrix element from the user, then I want to display the entire matrix. But it does not print properly, it prints the address of the elements, why it is not printing, the value? / Here is my code:

  #include & lt; Stdio.h & gt; Structure matrix {int n, m; Int a [100] [100]; } Array; Int main () {struct matrix * p; Int i, j; P = Mallok (size) (array); Scanf ("% d% d", & amp; p->, n; & amp; p- & gt; m); For (i = 0; i & lt; p- & gt; n; i ++) for (j = 0; j & lt; p-> gt; m + j ++) scanf ("% d" , P-> A [i] [j]); (I = 0; i & lt; p- & gt; n; i ++) {for (j = 0; j & lt; p-> gt; m + j ++) printf ("% d" , (P-> a [i] [ja])); Printf ("\ n"); }}  

  1. change scanf ("% d ", P-> a [i] [j]); to scanf ("% d", & amp; p-> a [i] [j]); scanf () to get the expected data for the code better to check the result.

      if (scanf ("% d", & amp; p-> [i] [j])! = 1) ohs ();  
  2. Enable all warnings on your compiler This problem is immediately popped up.

      #include & lt; Stdio.h & gt; Structure matrix {int n, m; Int a [100] [100]; } Array; Int main () {struct matrix * p; Int i, j; P = Mallok (size) (array); Scanf ("% d% d", & amp; p->, n; & amp; p- & gt; m); For (i = 0; i & lt; p- & gt; n; i ++) (j = 0; j & lt; p-> m; j ++) {// scanf (" % D ", p-> one [i] [j]); Scan ("% d", and p-> a [i] [j]); } (I = 0; i & lt; p- & gt; n; i ++) {for (j = 0; j & lt; p-> m; j ++) printf ("% d ", (P-> one [i] [j])); Printf ("\ n"); }}  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -