CodeBlanks Logo Icon CodeBlanks

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.

Practice 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").

Starter code

main.c
#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"));
    // security_check çağır ve Güvenlik yazdır
    // Bitti yazdır
    return 0;
}

Sample solution

main.c
#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;
}

Expected output

Proje başladı
Çekirdek başladı
Komut: 1
Güvenlik: 1
Bitti

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Match module to final role

Term Meaning
Kernel kernel_init()
Compiler parse_command()
Security security_check()
Exit printf Bitti

2 What is the final step of the project?

  • Only call security
  • Only call the kernel
  • Call all modules and print 'Bitti' Correct answer
  • Call nothing

Explanation: In the final step all modules are called and 'Bitti' is printed.

3 Complete the final printf

Question
printf("____
");
Answer
printf("Bitti
");

Explanation: printf("Bitti\n"); signals the program is done.

All lessons in Expert