Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #define ARR_LEN 6
  4. int main() {
  5. char buff[ARR_LEN];
  6. int i;
  7. for(i=0; i<ARR_LEN; i++){
  8. buff[i] = i + '0';
  9. }
  10. snprintf(buff, ARR_LEN, "012345");
  11. puts(buff);
  12. }
  13.  
  14. buffersnprintf.c: In function ‘main’:
  15. buffersnprintf.c:10:32: warning: ‘snprintf’ output truncated before the last format character [-Wformat-truncation=]
  16. snprintf(buff, ARR_LEN, "012345");
  17. ^
  18. buffersnprintf.c:10:1: note: ‘snprintf’ output 7 bytes into a destination of size 6
  19. snprintf(buff, ARR_LEN, "012345");
  20. ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement