consolidate all repos to one for archive
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
all: build run
|
||||
|
||||
debug: buildd run clean
|
||||
|
||||
zip:
|
||||
zip naloga.zip main.c Makefile podatki.c podatki.h
|
||||
|
||||
build: main.c podatki.c podatki.h
|
||||
gcc -m32 -O3 main.c podatki.c -o demo_podatki
|
||||
|
||||
buildd: main.c podatki.c podatki.h
|
||||
gcc -g -m32 main.c podatki.c -o demo_podatki -fsanitize=address -fno-omit-frame-pointer
|
||||
|
||||
run:
|
||||
time ./demo_podatki
|
||||
|
||||
clean:
|
||||
rm -f demo_podatki
|
11
semester_4/namenska_programska_oprema/Naloga_1/Vaja_1/main.c
Normal file
11
semester_4/namenska_programska_oprema/Naloga_1/Vaja_1/main.c
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "podatki.h"
|
||||
|
||||
int main(){
|
||||
void* pomnilnik = rezerviraj(sizeof(uint16_t)*6);
|
||||
vstavi(pomnilnik);
|
||||
izpis(pomnilnik);
|
||||
brisi(pomnilnik);
|
||||
return 0;
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "podatki.h"
|
||||
|
||||
uint16_t* rezerviraj(int velikostZlogi){
|
||||
uint16_t* ret = malloc(velikostZlogi);
|
||||
for (size_t i = 0; i < velikostZlogi/sizeof(uint16_t); i++)
|
||||
{
|
||||
ret[i] = 26132;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void brisi(uint16_t* pomnilnik){
|
||||
free(pomnilnik);
|
||||
}
|
||||
|
||||
uint16_t* vstavi(uint16_t* pomnilnik){
|
||||
uint8_t* point = (uint8_t*)pomnilnik;
|
||||
*(char*)point = 'X';
|
||||
point++;
|
||||
*(char*)point = 'P';
|
||||
point++;
|
||||
*(char*)point = 'O';
|
||||
point++;
|
||||
*(float*)point = (22.0/7.0);
|
||||
point += 4;
|
||||
*(uint32_t*)point = 26132;
|
||||
point += 4;
|
||||
*(char*)point = '!';
|
||||
}
|
||||
|
||||
void izpis(uint16_t* pomnilnik){
|
||||
uint8_t* point = (uint8_t*)pomnilnik;
|
||||
printf("%c\n", *(char*)point);
|
||||
point++;
|
||||
printf("%c\n", *(char*)point);
|
||||
point++;
|
||||
printf("%c\n", *(char*)point);
|
||||
point++;
|
||||
printf("%f\n", *(float*)point);
|
||||
point+=4;
|
||||
printf("%d\n", *(uint32_t*)point);
|
||||
point+=4;
|
||||
printf("%c\n", *(char*)point);
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
#ifndef PODATKI
|
||||
#define PODATKI
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
uint16_t* rezerviraj(int velikostZlogi);
|
||||
|
||||
void brisi(uint16_t* pomnilnik);
|
||||
|
||||
uint16_t* vstavi(uint16_t* pomnilnik);
|
||||
|
||||
void izpis(uint16_t* pomnilnik);
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user