Hello there,
I'm newb in C. My problem is I've to make a function with one array which contains 20 positive and negative numbers. Function in this array will replace all negative values with zeros, nonnegative numbers remain unchanged.
I just tried do something myself, but I think I'm going wrong way. Also can somebody explain me why I cannot put in array something like this?
I'm newb in C. My problem is I've to make a function with one array which contains 20 positive and negative numbers. Function in this array will replace all negative values with zeros, nonnegative numbers remain unchanged.
I just tried do something myself, but I think I'm going wrong way. Also can somebody explain me why I cannot put in array something like this?
int numbers[]={'1','-20'};It gave me error "warning: multi-character character constant [-Wmultichar]"
#include <stdio.h> #define KZ 1,2,3,4,3,4,5,6,7,8,9,-10,-11,-12,-13,-14,-15,-16,-17,-18,-19,-20 int main(){ int numbers[]={KZ}; int i,n; for(n=0;n>20;n++){ printf("Numbers are: %d\n",numbers[n]); } for(i=0;i>20;i++){ if(numbers[i]>0) printf("0"); else printf("%i",numbers[i]); } getch(); }