C언어 fwrite() fread()로 enum, struct 읽고 쓰기
#include <stdio.h> #include <errno.h> #include <string.h> typedef enum _product_size {SIZE_S = 1 , SIZE_M, SIZE_L, SIZE_XL, SIZE_XXL} PRODUCT_SIZE; typedef enum _product_type {TYPE_OUTER= 1 , TYPE_TOP, TYPE_BOTTOM} PRODUCT_TYPE; typedef struct _cloth { char product_name[ 64 ]; unsigned product_price; char brand_name[ 64 ]; PRODUCT_TYPE product_type; PRODUCT_SIZE product_size; } cloth; void printPS (PRODUCT_SIZE ps); void printPT (PRODUCT_TYPE pt); int main ( int argc, char const *argv[]) { /* code */ FILE *outfile = NULL ; FILE *infile = NULL ; int i = 0 ; int num_cloth = 0 ; cloth temp_product = { 0 }; printf ( "How many products are here?" ); scanf ( "%d" , &num_cloth); if (num_cloth > 0 ){ outfile = fopen ( "C: \\ temp \\ cloth.dat" , "w" ); if ( NULL != outfile){ ...