I am trying to convert my little endian to big endian by reversing the bytes but i get the same output as of the little endian. I have modified my code alot but the value remains the same. If someone could tell me where i am going wrong. Thank you for the help
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
FILE* input;
FILE* output;
input = fopen(argv[1],"r");
output = fopen(argv[2],"w");
int zipcode, population, value;
int popluationEndian;
unsigned char *convert = (unsigned char*) &population;
unsigned char temp[4];
int i;
while(fscanf(input,"%d %d\n",&zipcode, &population)!= EOF)
{
for(i = 0; i<4; i++)
{
temp[i] = convert[3-i];
}
popluationEndian = fwrite(&population,sizeof(int),1,output);
}
fclose(input);
fclose(output);
return 0;
}