This code assumes you have the _countof macro defined.
https://msdn.microsoft.com/en-us/library/ms175773.aspx[
^]
#include <stdio.h>
static long words[] = {10, 20, 30, 40, 50, 60, 70, 80, 90};
int main(int argc, char *argv[])
{
unsigned count = _countof(words);
unsigned half = _count / 2;
for (unsigned i = 0; i < half; i++)
{
long swap = words[i];
words[i] = words[count - i - 1];
words[count - i - 1] = swap;
}
for (unsigned i = 0; i < half; i++)
{
printf(" %ld", words[i]);
}
return 0;
}
</stdio.h>
You know, it would be simpler to just print the numbers in reverse order.
#include <stdio.h>
static long words[] = {10, 20, 30, 40, 50, 60, 70, 80, 90};
int main(int argc, char *argv[])
{
unsigned i = _countof(words);
while (i > 0)
{
printf(" %ld", words[--i]);
}
return 0;
}
</stdio.h>