Compare commits

...

5 Commits

Author SHA1 Message Date
436d5bb6d6 Fixed error at course of marks 2020-07-31 21:55:58 +07:00
2b3d65c582 Add linked list function and example code
Updated for read file function
2020-07-31 21:55:25 +07:00
7bce631799 Add read file functions and read welcome.txt data 2020-07-31 21:44:03 +07:00
5724110cbb Add read file and menu function and only struct 2020-07-31 21:35:47 +07:00
1ee2386f7c Add linkedlist in student tag 2020-07-31 21:32:40 +07:00
2 changed files with 54 additions and 1 deletions

Binary file not shown.

View File

@@ -1,5 +1,6 @@
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
struct person_tag
{
@@ -37,5 +38,57 @@ int main()
printf("Hello, %s \n", person2.name);
printf("Hello Ptr, %s \n", personPtr->name);
// using linkedlist
struct student_tag *first = NULL;
struct student_tag *second = NULL;
struct student_tag *third = NULL;
first = (struct student_tage *)malloc(sizeof(struct student_tag *));
struct course_tag c1 = {"Computer", 4, {1, 2, 3, 4}};
struct person_tag p1 = {"Sambo", "121214"};
first->course_info = c1;
first->student_info = p1;
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);
return 0;
}
}
void read_file()
{
// read the file here...
FILE *file;
char c;
if ((file = fopen("./../data/welcome.txt", "r")) == NULL)
{
printf("no file were found...!");
}
else
{
while ((c = getc(file)) != EOF)
{
printf("%c", c);
}
}
}
void menu(int menu)
{
// do something here...
switch (menu)
{
case 1:
printf("1. Student details...");
break;
default:
printf("No menu found here...!");
break;
}
}