// A function to print the notes for a given uid that match // an optional search string; // returns 0 at end of file, 1 if there are still more notes. int print_notes(int fd, int uid, char *searchstring) { int note_length; char byte = 0, note_buffer[100]; note_length = find_user_note(fd, uid); if (note_length == -1) // If end of file reached, return 0; // return 0. read(fd, note_buffer, note_length); // Read note data. note_buffer[note_length] = 0; // Terminate the string if (search_note(note_buffer, searchstring)) printf(note_buffer); return 1; }
int print_note(int fd, int uid, char *searchstring) { int note_length; char byte = 0, note_buffer[100]; note_length = find_user_note(fd, uid); if (note_length == -1) return 0; read(fd, note_buffer, note_length); note_buffer[note_length] = 0; if (search_note(note_buffer, searchstring)) printf(note_buffer); return 1; }
// A function to print the notes for a given uid that match // an optional search string // returns 0 at end of file, 1 if there are still more notes int print_notes(int fd, int uid, char *searchstring) { int note_length; char byte=0, note_buffer[100]; note_length = find_user_note(fd, uid); if(note_length == -1) // if end of file reached return 0; // return 0 read(fd, note_buffer, note_length); // read note data note_buffer[note_length] = 0; // terminate the string if(search_note(note_buffer, searchstring)) // if searchstring found printf(note_buffer); // print the note return 1; }