2023-04-22 15:35:32 +03:00
|
|
|
#include <stdio.h>
|
2023-05-06 18:10:38 +03:00
|
|
|
#include <stdlib.h>
|
2023-04-22 15:35:32 +03:00
|
|
|
|
2023-04-12 22:20:18 +03:00
|
|
|
int main()
|
|
|
|
{
|
2023-05-06 18:10:38 +03:00
|
|
|
void* ptr = malloc(10);
|
|
|
|
if (ptr == NULL)
|
|
|
|
{
|
|
|
|
perror("malloc");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
*(int*)ptr = 5;
|
|
|
|
putc('0' + *(int*)ptr, stdout);
|
|
|
|
return 0;
|
|
|
|
|
2023-04-25 14:50:26 +03:00
|
|
|
FILE* fp = fopen("/boot/grub/grub.cfg", "r");
|
|
|
|
if (fp == NULL)
|
|
|
|
{
|
|
|
|
perror("fopen");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
char buffer[128];
|
|
|
|
size_t nread = fread(buffer, 1, sizeof(buffer) - 1, fp);
|
|
|
|
if (nread == 0)
|
|
|
|
{
|
|
|
|
if (ferror(fp))
|
|
|
|
perror("fread");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
buffer[nread] = '\0';
|
|
|
|
fputs(buffer, stdout);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fclose(fp) == EOF)
|
|
|
|
{
|
|
|
|
perror("fclose");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2023-04-12 22:20:18 +03:00
|
|
|
return 0;
|
|
|
|
}
|