Skip to content

Commit

Permalink
Merge pull request #72 from ktauchathuranga/develop
Browse files Browse the repository at this point in the history
minor issues with functions fix
  • Loading branch information
ktauchathuranga authored May 6, 2024
2 parents cfc4c9e + 78b6d23 commit 6977c05
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 21 deletions.
37 changes: 28 additions & 9 deletions func.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,22 +442,27 @@ void tutReg()
printf("[-] Enter First Name: ");
fgets(firstname, sizeof(firstname), stdin);
firstname[strcspn(firstname, "\n")] = '\0';
getchar();

printf("[-] Enter Last Name: ");
fgets(lastname, sizeof(lastname), stdin);
lastname[strcspn(lastname, "\n")] = '\0';
getchar();

printf("[-] Enter Subject Specialization: ");
fgets(subject, sizeof(subject), stdin);
subject[strcspn(subject, "\n")] = '\0';
getchar();

printf("[-] Enter Contact Number: ");
fgets(contnumber, sizeof(contnumber), stdin);
contnumber[strcspn(contnumber, "\n")] = '\0';
getchar();

printf("[-] Enter Tutor Email: ");
fgets(email, sizeof(email), stdin);
email[strcspn(email, "\n")] = '\0';
getchar();

char *data;
asprintf(&data, "%d, '%s', '%s', '%s', '%s', '%s'", tutid + 1, firstname, lastname, subject, contnumber, email);
Expand Down Expand Up @@ -816,7 +821,7 @@ void editClass(){
printf("1. Edit Class Details\n");
printf("2. Display Class\n");
printf("3. Back to Manage Class Menu\n");
printf("0. Back to Main Menu\n");
// printf("0. Back to Main Menu\n");
printf("========================================\n");
printf("\n[-] Enter Your Choice: ");
scanf("%d",&choice);
Expand All @@ -835,11 +840,11 @@ void editClass(){
case 3:
manageClass();
break;
case 0:
// authSec();
printf("Returning to main menu.\n");
delay(1);
break;
// case 0:
// // authSec();
// printf("Returning to main menu.\n");
// delay(1);
// break;
default:
printf("[!] Invalid Choice.\n");
delay(1);
Expand Down Expand Up @@ -1376,13 +1381,19 @@ void insertClassData(int tutorid)
sqlite3_finalize(stmt);

printf("[-] Enter Class Name: ");
scanf("%s", className);
fgets(className, sizeof(className), stdin);
className[strcspn(className, "\n")] = '\0';
getchar();

printf("[-] Enter Class Time (00:00): ");
scanf("%s", classTime);
fgets(classTime, sizeof(classTime), stdin);
classTime[strcspn(classTime, "\n")] = '\0';
getchar();

printf("[-] Enter Class Days (day,day,day): ");
scanf("%s", classDays);
fgets(classDays, sizeof(classDays), stdin);
classDays[strcspn(classDays, "\n")] = '\0';
getchar();

char insertSQL[300];
sprintf(insertSQL, "INSERT INTO Classes (ClassID, ClassName, TutorID, ClassTime, ClassDays) VALUES (%d, '%s', %d, '%s', '%s');", lastClassID + 1, className, tutorid, classTime, classDays);
Expand All @@ -1399,6 +1410,9 @@ void insertClassData(int tutorid)
}

sqlite3_close(db);

clearInputBuffer();

}

void clearScreen() {
Expand All @@ -1415,4 +1429,9 @@ void delay(int time) {
#else
sleep(time);
#endif
}

void clearInputBuffer() {
int c;
while ((c = getchar()) != '\n' && c != EOF) { }
}
1 change: 1 addition & 0 deletions func.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ void insertClassData(int tutorid);
void displayclasslist();
void clearScreen();
void delay(int time);
void clearInputBuffer();

#endif
4 changes: 3 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ int main(int argc, char* argv[]) {
int loginAtt = 0;
char* loadingSymbols = "-\\|/";
int numSymbols = 4;
const char* version = "v2.1.1";
const char* version = "v2.1.2";

printf("\n");
printf("========================================\n");
Expand Down Expand Up @@ -43,6 +43,8 @@ int main(int argc, char* argv[]) {
} else {
printf("[!] Login Failed\n");
loginAtt++;

clearScreen();
}
}

Expand Down
Binary file modified resources/ADDSAMPLEDATA
Binary file not shown.
Binary file modified resources/ADDSAMPLEDATA.exe
Binary file not shown.
Binary file modified resources/DAYUPDATE
Binary file not shown.
Binary file modified resources/DAYUPDATE.exe
Binary file not shown.
Binary file modified resources/MONTHUPDATE
Binary file not shown.
Binary file modified resources/MONTHUPDATE.exe
Binary file not shown.
18 changes: 9 additions & 9 deletions resources/addsampledata.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ int main(int argc, char *argv[])

const char *enrollmentsData[] = {
"1, 1, 1, '2024-01-01'",
"2, 2, 2, '2024-01-02'",
"3, 3, 3, '2024-02-01'",
"4, 4, 4, '2024-02-02'",
"5, 5, 1, '2024-03-01'",
"6, 6, 2, '2024-03-02'",
"7, 7, 3, '2024-04-01'",
"8, 8, 4, '2024-04-02'",
"9, 9, 5, '2024-05-01'",
"10, 10, 1, '2024-05-02'"};
"2, 2, 2, '2024-01-01'",
"3, 3, 3, '2024-01-01'",
"4, 4, 4, '2024-01-01'",
"5, 5, 1, '2024-01-01'",
"6, 6, 2, '2024-01-01'",
"7, 7, 3, '2024-01-01'",
"8, 8, 4, '2024-01-01'",
"9, 9, 5, '2024-01-01'",
"10, 10, 1, '2024-01-01'"};

for (int i = 0; i < 10; i++)
{
Expand Down
2 changes: 1 addition & 1 deletion resources/dayUpdate.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ int executeSQL(sqlite3 *db, const char *sql)
int main()
{
sqlite3 *db;
int rc = sqlite3_open("../tcms.db", &db);
int rc = sqlite3_open("tcms.db", &db);
if (rc)
{
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
Expand Down
2 changes: 1 addition & 1 deletion resources/monthUpdate.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ int executeSQL(sqlite3 *db, const char *sql)
int main()
{
sqlite3 *db;
int rc = sqlite3_open("../tcms.db", &db);
int rc = sqlite3_open("tcms.db", &db);
if (rc)
{
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
Expand Down

0 comments on commit 6977c05

Please sign in to comment.