setup for debugging

This commit is contained in:
kevinnls committed 2021-09-20 02:18:17 +05:30
1 parent 9b10e5df1e
commit 2818ddaf36
1 file changed
+15 -5
+15 -5
View File
@@ -1,9 +1,17 @@
#include<stdio.h> #include<stdio.h>
#include<stdlib.h> #include<stdlib.h>
#include<string.h>
int* sort(int*, int); int* sort(int*, int);
int DEBUG;
int main(){ int main(){
char* _debug = getenv("DEBUG");
if(_debug){
DEBUG = strcmp(_debug,"1") == 0 ? 1 : 0;
}
int arr[] = {1,2,4,593,29,19,0}; int arr[] = {1,2,4,593,29,19,0};
int arr_len = sizeof(arr) / sizeof(arr[0]); int arr_len = sizeof(arr) / sizeof(arr[0]);
sort(arr, arr_len); sort(arr, arr_len);
@@ -13,11 +21,13 @@ int main(){
int* sort(int* arr, int length){ int* sort(int* arr, int length){
printf("length of array to be sorted: %d\n", length); if(DEBUG){
printf("elements of array to be sorted: "); printf("length of array to be sorted: %d\n", length);
for(int i=0; i<length; i++){ printf("elements of array to be sorted: ");
if(i!=0) printf(", "); for(int i=0; i<length; i++){
printf("%d", arr[i]); if(i!=0) printf(", ");
printf("%d", arr[i]);
}
} }
return arr; return arr;