-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnote.c
More file actions
45 lines (35 loc) · 1.06 KB
/
note.c
File metadata and controls
45 lines (35 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "note.h"
void fillNote(Note* note,char* title, char* description){
memcpy(¬e->title, title, strlen(title) + 1);
memcpy(¬e->description, description, strlen(description) + 1);
}
void printNote(Note* note){
printf("Title: %s\n", note->title);
printf("Description: %s\n",note->description);
}
void printShortNote(Note* note){
printf("%30s\n", note->title);
}
void setupNote(Note* note){
char* title = malloc(sizeof(char) * 256);
char* description = malloc(sizeof(char) * 1024 * 16);
printf("Title: ");
gets(title);
printf("Description: ");
gets(description);
fillNote(note,title,description);
}
void changeNote(Note* note) {
char* title = malloc(sizeof(char) * 256);
char* description = malloc(sizeof(char) * 8 * 256);
printf("Title[%s]: ", note->title);
gets(title);
printf("Description[%s]: ", note->description);
gets(description);
if(strlen(title) != 0)
memcpy(note->title, title, strlen(title) + 1);
if(strlen(description) != 0)
memcpy(note->description, description, strlen(description) + 1);
free(title);
free(description);
}