to put element in two dimensional array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pritivyas
    New Member
    • Oct 2013
    • 1

    to put element in two dimensional array

    I have already data in two dimensional matrix but some cell is empty.Now i want to put 0 in blank cell.
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    This rather depends on how you have declared your matrix.

    Comment

    • stdq
      New Member
      • Apr 2013
      • 94

      #3
      Are you sure those cells are empty? They may contain garbage values from memory. A solution would be to declare the array and already initialize all elements to 0 ( finishing the statement with = { 0 }; ) and then fill in the positions you want with data. That of course assuming your matrix is of a numeric data type. For example, to declare and initialize a matrix (with 10 rows and 5 columns) of the int data type with 0 in all positions:

      Code:
      int matrix[10][5] = { 0 };

      Comment

      Working...