Skip to content

Instantly share code, notes, and snippets.

@tivrfoa
Created May 17, 2013 17:43
Show Gist options
  • Save tivrfoa/5600696 to your computer and use it in GitHub Desktop.
Save tivrfoa/5600696 to your computer and use it in GitHub Desktop.
Memset matrix test. memset when using the size of the matrix, change the values in all dimensions.
#include <stdio.h> // for printf
#include <cstring> // for memset
int main(int argc, char *argv[])
{
int xx[2][2] = {{1,1},{2,2}};
printf("{{%d,%d},{%d,%d}}\n", xx[0][0], xx[0][1], xx[1][0], xx[1][1]);
memset(xx, 0, sizeof(xx)); // change to {{0,0},{0,0}}
printf("{{%d,%d},{%d,%d}}\n", xx[0][0], xx[0][1], xx[1][0], xx[1][1]);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment