nieco
This commit is contained in:
parent
1422955906
commit
c631c7194c
@ -35,6 +35,9 @@ add_executable(skola calc.c
|
||||
stringy.h
|
||||
funkcie.c
|
||||
funkcie.h
|
||||
termstuff.c
|
||||
stringyreloaded.c
|
||||
stringyreloaded.h
|
||||
)
|
||||
|
||||
target_link_libraries(skola m)
|
||||
target_link_libraries(skola m ncurses)
|
||||
|
19
funkcie.c
19
funkcie.c
@ -13,6 +13,14 @@ int obsahObdlznika(int w, int h) {
|
||||
return w * h;
|
||||
}
|
||||
|
||||
int factorial(int cislo) {
|
||||
if(cislo == 1 || cislo == 0) {
|
||||
return 1;
|
||||
} else {
|
||||
return cislo * factorial(cislo - 1);
|
||||
}
|
||||
}
|
||||
|
||||
int funkcie(void) {
|
||||
greet("Jožo");
|
||||
greet("Fero");
|
||||
@ -78,3 +86,14 @@ int counterChars() {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int facttest() {
|
||||
for (int i = 0 ; i < 11 ; i++){
|
||||
printf("%d: %d\n", i, factorial(i));
|
||||
}
|
||||
int infact;
|
||||
printf("Zadaj číslo: ");
|
||||
scanf("%d", &infact);
|
||||
printf("Factorial z %d je %d", infact, factorial(infact));
|
||||
return 0;
|
||||
}
|
@ -1,2 +1,4 @@
|
||||
int funkcie();
|
||||
int counterChars();
|
||||
int factorial(int cislo);
|
||||
int facttest();
|
4
main.c
4
main.c
@ -1,5 +1,5 @@
|
||||
#include "funkcie.h"
|
||||
#include "stringyreloaded.h"
|
||||
|
||||
int main() {
|
||||
return counterChars();
|
||||
return stringyreloaded();
|
||||
}
|
45
stringyreloaded.c
Normal file
45
stringyreloaded.c
Normal file
@ -0,0 +1,45 @@
|
||||
//
|
||||
// Created by bruno on 3/18/24.
|
||||
//
|
||||
|
||||
#include "stringyreloaded.h"
|
||||
#include "curses.h"
|
||||
#include "string.h"
|
||||
|
||||
int stringyreloaded() {
|
||||
char meno[64];
|
||||
char adresa[64];
|
||||
char telefon[10];
|
||||
|
||||
char *s1 = "Ahoj";
|
||||
char s2[21];
|
||||
|
||||
FILE *fw;
|
||||
fw = fopen("test.txt", "w");
|
||||
|
||||
strcpy(s2, "Hello");
|
||||
strcat(s2, " + ");
|
||||
strcat(s2, s1);
|
||||
|
||||
fprintf(fw, "Dĺžka reťazca %s je %lu.\n", s1, strlen(s1));
|
||||
fprintf(fw, "Dĺžka reťazca %s je %lu.\n", s2, strlen(s2));
|
||||
|
||||
|
||||
initscr();
|
||||
clear();
|
||||
puts("Zadaj meno a priezvisko: ");
|
||||
getnstr(meno, 63);
|
||||
puts("Zadaj adresu: ");
|
||||
getnstr(adresa, 63);
|
||||
puts("Zadaj telefón: ");
|
||||
getnstr(telefon, 9);
|
||||
fputs("Zadal si:\n", fw);
|
||||
fputs(meno, fw);
|
||||
fputc('\n', fw);
|
||||
fputs(adresa, fw);
|
||||
fputc('\n', fw);
|
||||
fputs(telefon, fw);
|
||||
fputc('\n', fw);
|
||||
fclose(fw);
|
||||
return 0;
|
||||
}
|
1
stringyreloaded.h
Normal file
1
stringyreloaded.h
Normal file
@ -0,0 +1 @@
|
||||
int stringyreloaded();
|
Loading…
Reference in New Issue
Block a user