Created
September 29, 2015 16:15
-
-
Save chadluo/81bb48551e7651fa72ba to your computer and use it in GitHub Desktop.
a trivial array pretty print.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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