Skip to content

Instantly share code, notes, and snippets.

@chadluo
Created September 29, 2015 16:15
Show Gist options
  • Select an option

  • Save chadluo/81bb48551e7651fa72ba to your computer and use it in GitHub Desktop.

Select an option

Save chadluo/81bb48551e7651fa72ba to your computer and use it in GitHub Desktop.
a trivial array pretty print.
#include <stdio.h>
int main() {
int arr[] = {1, 2, 3, 4, 5};
int size = 5;
for (int i = 0; i < size; i++)
printf((i == 0 ? "[%d" : i == size - 1 ? ", %d]\n" : ", %d"), arr[i]);
// "[1, 2, 3, 4, 5]"
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment