fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. void my_memset(void* ptr, int n, size_t size)
  5. {
  6. unsigned int i;
  7.  
  8. for( i = 0; i < size; ++i, ++(char*)ptr )
  9. *(char*)ptr = n;
  10. }
  11.  
  12. void printArr(int* arr, int n)
  13. {
  14. int i;
  15. for( i = 0; i < n; ++i )
  16. printf("%d ",arr[i]);
  17. printf("\n");
  18. }
  19.  
  20. int main()
  21. {
  22. int my_arr[5], arr[5];
  23.  
  24. my_memset(my_arr,3,sizeof(my_arr));
  25.  
  26. memset(arr,0,sizeof(arr));
  27.  
  28. printArr(my_arr,5);
  29.  
  30. printArr(arr,5);
  31.  
  32. return 0;
  33. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘void my_memset(void*, int, size_t)’:
prog.cpp:8: error: lvalue required as increment operand
stdout

Standard output is empty