fork download
  1. #include <stdio.h>
  2.  
  3. void printhexchars(const char* str)
  4. {
  5. while(*str)
  6. {
  7. printf("%03d ", *(str++));
  8. }
  9. /* print last character after while loop: '\0' */
  10. printf("%03d ", *str);
  11. }
  12.  
  13. int main()
  14. {
  15. char cr[3] = { 'a', 'b' };
  16. int ar[3] = { 1, 2 };
  17.  
  18. printf("character array output using printf() : ");
  19. printhexchars(cr);
  20.  
  21. printf("\n\nInteger array output using printf() : ");
  22. printhexchars(ar);
  23. printf("\n");
  24.  
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0s 9432KB
stdin
Standard input is empty
stdout
character array output using printf() : 097 098 000 

Integer array output using printf() : 001 000