(C/C++) memset
1267 ワード
C言語:
memset extern void *memset(void *buffer,int c,int count); #include機能:bufferが指すメモリ領域の前countバイトを文字cに設定説明:bufferへのポインタを返す.
char a[100]; memset(a,'\0',sizeof(a));
C#:
byte[] test = new byte[65536];
Array.Clear(test,0,test.Length);
You could use Enumerable.Repeat :
The first parameter is the element you want repeated, and the second parameter is the number of times to repeat it.
This is OK for small arrays but you should use the looping method if you are dealing with very large arrays and performance is a concern.
memset extern void *memset(void *buffer,int c,int count); #include
char a[100]; memset(a,'\0',sizeof(a));
C#:
byte[] test = new byte[65536];
Array.Clear(test,0,test.Length);
You could use Enumerable.Repeat :
byte[] a = Enumerable.Repeat((byte)10, 100).ToArray();
The first parameter is the element you want repeated, and the second parameter is the number of times to repeat it.
This is OK for small arrays but you should use the looping method if you are dealing with very large arrays and performance is a concern.