Программирование в стандарте POSIX


Пример 5.19 - часть 2


fputc (a.c[1], output); fputc (a.c[2], output); fputc (a.c[3], output);

#elif __BYTE_ORDER == __LITTLE_ENDIAN

fputc (a.c[2], output); fputc (a.c[1], output);

fputc (a.c[0], output);

#elif __BYTE_ORDER == __PDP_ENDIAN

fputc (a.c[0], output); fputc (a.c[3], output); fputc (a.c[2], output);

#else

#error "Unknown endian"

#endif

}

if (tl == 2) {

#if __BYTE_ORDER == __BIG_ENDIAN

fputc (a.c[1], output); fputc (a.c[2],

output);

#elif __BYTE_ORDER == __LITTLE_ENDIAN

fputc (a.c[2], output); fputc (a.c[1],

output);

#elif __BYTE_ORDER == __PDP_ENDIAN

fputc (a.c[0], output); fputc (a.c[3],

output);

#else

#error "Unknown endian"

#endif

}

if (tl == 1) {

#if __BYTE_ORDER == __BIG_ENDIAN

fputc (a.c[1], output);

#elif __BYTE_ORDER == __LITTLE_ENDIAN

fputc (a.c[2], output);

#elif __BYTE_ORDER == __PDP_ENDIAN

fputc (a.c[0], output);

#else

#error "Unknown endian"

#endif

}

}

fclose (input);

fclose (output);

return (0);

}




Начало  Назад  Вперед



Книжный магазин