2020-07-31 21:25:15 +07:00
|
|
|
#include "stdio.h"
|
|
|
|
#include "string.h"
|
2020-07-31 21:55:25 +07:00
|
|
|
#include "stdlib.h"
|
2020-08-01 20:03:17 +07:00
|
|
|
#include "util.c"
|
2020-07-31 21:25:15 +07:00
|
|
|
|
|
|
|
struct person_tag
|
|
|
|
{
|
|
|
|
char name[20];
|
|
|
|
char id[10];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct course_tag
|
|
|
|
{
|
|
|
|
char course_name[20];
|
|
|
|
int no_of_units;
|
|
|
|
int marks[4];
|
|
|
|
float avg;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct student_tag
|
|
|
|
{
|
|
|
|
struct person_tag student_info;
|
|
|
|
struct course_tag course_info;
|
|
|
|
struct student_tag *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2020-08-01 08:49:16 +07:00
|
|
|
int selected;
|
2020-07-31 21:25:15 +07:00
|
|
|
struct person_tag person, person2 = {"Chea", "4567892"}, *personPtr;
|
|
|
|
|
|
|
|
// strcpy style
|
|
|
|
strcpy(person.id, "2345678");
|
|
|
|
strcpy(person.name, "Sambo");
|
|
|
|
|
|
|
|
personPtr = &person;
|
|
|
|
|
|
|
|
printf("Hello, %s \n", person.name);
|
|
|
|
printf("Hello, %s \n", person2.name);
|
|
|
|
printf("Hello Ptr, %s \n", personPtr->name);
|
|
|
|
|
2020-07-31 21:32:40 +07:00
|
|
|
// using linkedlist
|
2020-07-31 21:55:25 +07:00
|
|
|
struct student_tag *first = NULL;
|
|
|
|
struct student_tag *second = NULL;
|
|
|
|
struct student_tag *third = NULL;
|
|
|
|
|
|
|
|
first = (struct student_tage *)malloc(sizeof(struct student_tag *));
|
2020-07-31 21:32:40 +07:00
|
|
|
|
2020-07-31 21:55:25 +07:00
|
|
|
struct course_tag c1 = {"Computer", 4, {1, 2, 3, 4}};
|
|
|
|
struct person_tag p1 = {"Sambo", "121214"};
|
2020-07-31 21:32:40 +07:00
|
|
|
first->course_info = c1;
|
|
|
|
first->student_info = p1;
|
2020-07-31 21:55:25 +07:00
|
|
|
first->next = second;
|
|
|
|
|
|
|
|
printf("Student name: %s \n", first->student_info.name);
|
|
|
|
printf("Student id: %s \n", first->student_info.id);
|
|
|
|
printf("Course name: %s \n", first->course_info.course_name);
|
|
|
|
printf("Course of units: %d", first->course_info.no_of_units);
|
2020-07-31 21:32:40 +07:00
|
|
|
|
2020-08-01 08:49:16 +07:00
|
|
|
read_file("./../data/welcome.txt");
|
|
|
|
|
2020-08-01 22:10:24 +07:00
|
|
|
display_menu();
|
2020-08-01 08:49:16 +07:00
|
|
|
|
2020-08-01 20:03:17 +07:00
|
|
|
newline();
|
|
|
|
|
|
|
|
// scanf("\nenter the option: ", selected);
|
|
|
|
|
|
|
|
// menu(selected);
|
2020-08-01 08:49:16 +07:00
|
|
|
|
2020-07-31 21:25:15 +07:00
|
|
|
return 0;
|
2020-07-31 21:35:47 +07:00
|
|
|
}
|
|
|
|
|
2020-08-01 08:49:16 +07:00
|
|
|
void read_file(char *filename)
|
2020-07-31 21:55:25 +07:00
|
|
|
{
|
2020-07-31 21:35:47 +07:00
|
|
|
// read the file here...
|
2020-07-31 21:44:03 +07:00
|
|
|
FILE *file;
|
|
|
|
char c;
|
|
|
|
|
2020-08-01 08:49:16 +07:00
|
|
|
if ((file = fopen(filename, "r")) == NULL)
|
2020-07-31 21:55:25 +07:00
|
|
|
{
|
2020-07-31 21:44:03 +07:00
|
|
|
printf("no file were found...!");
|
2020-07-31 21:55:25 +07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-07-31 21:44:03 +07:00
|
|
|
while ((c = getc(file)) != EOF)
|
|
|
|
{
|
|
|
|
printf("%c", c);
|
|
|
|
}
|
|
|
|
}
|
2020-07-31 21:35:47 +07:00
|
|
|
}
|
|
|
|
|
2020-07-31 21:55:25 +07:00
|
|
|
void menu(int menu)
|
|
|
|
{
|
2020-07-31 21:44:03 +07:00
|
|
|
switch (menu)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
printf("1. Student details...");
|
|
|
|
break;
|
2020-07-31 21:55:25 +07:00
|
|
|
|
2020-07-31 21:44:03 +07:00
|
|
|
default:
|
|
|
|
printf("No menu found here...!");
|
|
|
|
break;
|
|
|
|
}
|
2020-07-31 21:35:47 +07:00
|
|
|
}
|
2020-08-01 08:49:16 +07:00
|
|
|
|
2020-08-01 22:10:24 +07:00
|
|
|
void display_menu()
|
|
|
|
{
|
2020-08-01 08:49:16 +07:00
|
|
|
printf("\n");
|
|
|
|
read_file("./../note/section1.txt");
|
2020-08-01 18:59:41 +07:00
|
|
|
}
|
|
|
|
|
2020-08-01 22:10:24 +07:00
|
|
|
void display_students()
|
|
|
|
{
|
2020-08-01 20:03:17 +07:00
|
|
|
}
|
|
|
|
|
2020-08-01 22:10:24 +07:00
|
|
|
void search_student()
|
|
|
|
{
|
2020-08-01 20:03:17 +07:00
|
|
|
}
|
|
|
|
|
2020-08-01 22:10:24 +07:00
|
|
|
void find_maximum()
|
|
|
|
{
|
2020-08-01 20:03:17 +07:00
|
|
|
}
|
|
|
|
|
2020-08-01 22:10:24 +07:00
|
|
|
void find_failed()
|
|
|
|
{
|
2020-08-01 20:03:17 +07:00
|
|
|
}
|
|
|
|
|
2020-08-01 22:10:24 +07:00
|
|
|
void update_file()
|
|
|
|
{
|
2020-08-01 20:03:17 +07:00
|
|
|
}
|
|
|
|
|
2020-08-01 22:10:24 +07:00
|
|
|
void exit_program()
|
|
|
|
{
|
2020-08-01 20:03:17 +07:00
|
|
|
println("Goodbye...");
|
2020-08-01 08:49:16 +07:00
|
|
|
}
|