I am trying to reverse an array so that I can store it into an another array, but I am not having any luck. Here is what my code looks like, all help is appreciated. Thanks!
char array1[50];
int count1=50;
int count2=0;
for(count1=50; count1>=0;count1--){
array1[count2]=array[count1];
count2++;
}
/*
Some information about my code:
This is taking place in a function. Array only holds integer values, obviously stored as chars. I need all of the integers in array to be reversed(for example, if array held the numbers 1-10 I would want it to hold 10-1). I do not know the size of array1, but I do not expect it to ever be longer than 50. I need the reverse of array to be stored as an array.Would it work better to make count1 equal to the size of(sizeof) array1?
All suggestions welcome, thanks for looking. */
char array1[50];
int count1=50;
int count2=0;
for(count1=50; count1>=0;count1--){
array1[count2]=array[count1];
count2++;
}
/*
Some information about my code:
This is taking place in a function. Array only holds integer values, obviously stored as chars. I need all of the integers in array to be reversed(for example, if array held the numbers 1-10 I would want it to hold 10-1). I do not know the size of array1, but I do not expect it to ever be longer than 50. I need the reverse of array to be stored as an array.Would it work better to make count1 equal to the size of(sizeof) array1?
All suggestions welcome, thanks for looking. */
Last edited: