fork(1) download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. struct _B {
  5. char a[8];
  6. char b[16];
  7. } typedef B;
  8.  
  9. int main(void) {
  10. B st;
  11. memset(st.b, 1, sizeof(st.b));
  12. int len = snprintf(st.a, sizeof(st.a), "%s", st.b);
  13. st.a[len - 1] = '\0';
  14.  
  15. for (int i = 0; i < sizeof(st.a); i++) {
  16. printf("%d ", st.a[i]);
  17. }
  18.  
  19. printf("\n");
  20.  
  21. for (int i = 0; i < sizeof(st.b); i++) {
  22. printf("%d ", st.b[i]);
  23. }
  24.  
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0s 2292KB
stdin
Standard input is empty
stdout
1 1 1 1 1 1 1 0 
1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1