/* -------------------------------------------------------------------------- */ int addnumber ( struct BOOK *data ) { SINT check=0; int size = 0; char baf[256]; memset( &baf[0], 0, sizeof( baf ) ); /* 引数チェック---------------------------------------------------------- */ if( data == NULL ) { return ERR; } cls( ); while( 1 ) { locate( 0, 0 ); check=record_print( data ); if (check==ERR) { return ERR; } locate( 5, 12 ); printf( " " ); locate( 5, 12 ); gets( &baf[0] ); size = strlen( &baf[0] ); if( size < 18 ) { break; } cls( ); locate( 7, 0 ); printf( "18バイトで入力してください" ); } strcpy( &data->number[0], &baf[0] ); return OK; }
/* -------------------------------------------------------------------------- */ int addpost ( struct BOOK *data ) { SINT check = 0; int key = 0; char baf[8]; memset( &baf[0], 0, sizeof( baf )); int index = 0; cls( ); check=record_print( data ); if (check==ERR) { return ERR; } while( 1 ) { key = getch( ); if(( key >= 48) && (key <= 57) && (index < 7) ) { baf[index] = key; check=post_print( &baf[0] ); if (check==ERR) { return ERR; } index++; } if( (key == 10) && (index == 7) ) { break; } } strcpy( &data->post[0], &baf[0] ); return OK; }
static void mnode_print(struct MNode *root) { if (root->left) mnode_print(root->left); record_print(root->row); if (root->right) mnode_print(root->right); }
void phone_book_unload_to_file(Phone_Book *pb) { FILE *output = fopen(file_name, "w"); for (int i = 0; i < pb->used; i++) { if (pb->v[i].id != -1) { record_print(&pb->v[i], output); //fprintf(output, "%d %s %s\n", pb->v[i].id, pb->v[i].name, pb->v[i].num); fflush(output); } } fclose(output); phone_book_free(pb); }
/* -------------------------------------------------------------------------- */ int addkana ( struct BOOK *data ) { int size = 0; int check = 0; int returncheck = 0; int index = 0; char baf[256]; memset( &baf[0], 0, sizeof( baf ) ); /* 引数チェック---------------------------------------------------------- */ if( data == NULL ) { return ERR; } cls( ); while( 1 ) { locate( 0, 0 ); returncheck = record_print( data ); if( returncheck == ERR ) { return ERR; } locate( 2, 12 ); printf( " " ); locate( 2, 12 ); gets( &baf[0] ); size = strlen( &baf[0] ); if( size < 30 ) { // for (index = 0; index < size; index++) { // if(baf[index]>='ヲ'&&baf[index]<'゚'|| // baf[index]>='0'&&baf[index]<='9'|| // baf[index]>='a'&&baf[index]<='z'){ // check++; // }else{ // break; // } // } // if (size==check) { break; // }else{ // cls(); // locate(7,0); // printf("使えない文字が含まれています"); // } } else { cls( ); locate( 7, 0 ); printf( "30バイトで入力してください" ); } } strcpy( &data->kana[0], &baf[0] ); return OK; }
void phone_book_find_num(Phone_Book *pb, char *num) { if (!is_num(num)) { return; } str_to_number(num, num); for (int i = 0; i < pb->used; i++) { char *cur_num = malloc(strlen(pb->v[i].num) * sizeof(char)); str_to_number(cur_num, pb->v[i].num); if (!strcmp(cur_num, num)) { record_print(&pb->v[i], stdout); } free(cur_num); } }
void phone_book_find_name(Phone_Book *pb, char *name) { if (!is_name(name)) { return; } str_to_lower(name, name); for (int i = 0; i < pb->used; i++) { char *cur_name = malloc(strlen(pb->v[i].name) * sizeof(char)); str_to_lower(cur_name, pb->v[i].name); if (strstr(cur_name, name)) { record_print(&pb->v[i], stdout); } free(cur_name); } }
int main(int argc, char **argv) { char c = 0; record_init(); while (c != '.') { print_prompt(); c = read_char(); eat_extra_input(); if (c != '.') { record_char(c); echo_char(c); } } record_print(); return 0; }
void database_print(database_t *database) { size_t i; printf(" File: %s\n", database->filename); printf(" Number of Fields: %d\n", (int) database->num_fields); printf(" Fields:\n"); for(i = 0; i < database->num_fields; i++) { printf(" %s\n", database->fields[i]); } for(i = 0; i < array_size(database->records); i++) { record_print(array_get(database->records, i)); } }