C
Putting it together
Combine all expert topics into a working mini app.
Putting it together
In the final lesson you combine all pieces. main calls kernel_init, parse_command and security_check in sequence. Each call's result is printed; the program ends with the "Bitti" message.
This models the flow of a system app: the kernel is prepared first, then commands are parsed, and every input passes the security check. The three modules — kernel, compiler and security — run inside one main. The previous lesson's solution is in the starting code; you only add the security_check call and the "Bitti" message. The program's full output is deterministic.
System flow
The integrated program's flow: main first prints "Proje başladı", then prepares the kernel with kernel_init(). Next it parses the command with parse_command("help") and prints the result.
The next step is the security check with security_check("test", 4); the result is printed. Finally the "Bitti" message ends the program. This flow shows a simplified version of a real system's boot and command-processing steps. Each module is called once; the output is deterministic and identical on every run.
Exercise Do the final integration
In main after printf("Komut: %d\n", parse_command("help")) add printf("Güvenlik: %d\n", security_check("test", 4)). End with printf("Bitti\n").
Show example solution
#include <stdio.h>
#include <string.h>
void kernel_init(void);
int parse_command(const char *cmd);
int security_check(const char *buf, int len);
void kernel_init(void) {
printf("Çekirdek başladı\n");
}
int syscall(int num) {
return num * 2;
}
int parse_command(const char *cmd) {
if (strcmp(cmd, "help") == 0) return 1;
if (strcmp(cmd, "exit") == 0) return 2;
return 0;
}
int security_check(const char *buf, int len) {
if (len < 0 || len > 16) return 0;
if (buf == NULL) return 0;
return 1;
}
int main(void) {
printf("Proje başladı\n");
kernel_init();
printf("Komut: %d\n", parse_command("help"));
printf("Güvenlik: %d\n", security_check("test", 4));
printf("Bitti\n");
return 0;
}
Test yourself
-
Match module to final role
- Kernel
- kernel_init()
- Compiler
- parse_command()
- Security
- security_check()
- Exit
- printf Bitti
-
What is the final step of the project?
- Only call security
- Only call the kernel
- Call all modules and print 'Bitti'
- Call nothing
Show answer
Call all modules and print 'Bitti' — In the final step all modules are called and 'Bitti' is printed.
-
Complete the final printf
printf("____
");
Show answer
printf("Bitti
");
Next lesson: Expert section exam