Write a function to check if a machine uses little endian or big endian notation.
write the function checkEndianess(), complete the main function implementation to print the value returned by the function and print if the machine is “Little Endian” or “Big Endian”, compile and run the program.
The function checkEndianess() should return the following values:
• 0 if the architecture is "Little Endian"
• 1 if the architecture is "Big Endian".
#include
int main()
{
int check; // Variable: "check" will hold the value returned by the function
//Call the function to check the Endianness here
// This is where your function will be called to return endianness check = checkEndianess ();
// TODO for TAs and Students who will use this function to check the student function
// TODO Write the code to check the value returned by the function
// TODO print if the system uses little Endian or big Endian notation
return(0);
}
/* Function "checkEndianess" checks the Endianness of the machine on which this program is executed. The function should return 0 if the architecture is "Little Endian" and return 1 if the architecture is "Big Endian". */
int checkEndianess ()
{
}
Please note that if you implement the function checkEndianess in a separate file other than the file containing the main function, you need to declare this function as an extern in the file containing the main function
#include <stdio.h>
int checkEndianess ();
int main(){
int check;
check = checkEndianess();
if(check == 0)
printf("Little Endian\n");
else
printf("Big Endian\n");
return(0);
}
int checkEndianess (){
unsigned int check = 1;
char *var = (char*)✓
if (*var != 0)
return 0;
return 1;
}
=============================================
SEE OUTPUT
Thanks, PLEASE COMMENT if there is any concern.
Get Answers For Free
Most questions answered within 1 hours.