I can't get a two-dimensional mass. Please help.



  • I've been dealing with the problem of the withdrawal. The challenge has been to fill a range of numbers that fall across digonals and meals in the corners, and the rest is empty, but the problem is the volume is right, but when I want to pull through printf_s('%s array,[j][i]); makes a mistake Unhandled exception at 0x7A6028BC (ucrtbased.dll) in Project1.exe: 0xC000 Access:

    #include <stdio.h>
    #include <stdlib.h>
    

    int main() {
    int n = 10;
    char array[10][10];
    int i, j, k = 0;

    for (i = 0; i &lt; 10; i++) {
        for (j = 0; j &lt; 10; j++) {
            array[i][j] = " ";
        }
    }
    
    array[0][9] = 1;
    array[9][0] = 1;
    
    
    for (i = 0; i &lt; 10; i++) {
        array[i][i] = n;
        n--;
    }
    
    
    for (i = 0; i &lt; 10; i++) {
        for (j = 0; j &lt; 10; j++) {
            printf_s("%s", array[j][i]);
        }
        printf_s("\n", "");
    }
    

    }



  • In your first line

    array[i][j] = " ";
    

    where the arr is a mass of char types, and you're writing that line. Also in the line.

    printf_s("%s", array[j][i]);
    

    The formatting shall take place with the elemet charSo instead %s Please. %c

    In the line.

    printf_s("\n", "");
    

    You're gonna have to clean up the trivial argument.

    Also replace everything. printf_sprintf



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2