mirror of
https://git.k0rb4k.net/K0RB4K/qotd.git
synced 2026-09-26 21:31:01 +00:00
start quote selection implementation
This commit is contained in:
+1
-1
@@ -3,4 +3,4 @@ project(qotd C)
|
|||||||
|
|
||||||
set(CMAKE_C_STANDARD 99)
|
set(CMAKE_C_STANDARD 99)
|
||||||
|
|
||||||
add_executable(qotd main.c)
|
add_executable(qotd main.c quote.c quote.h server.c server.h)
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
//
|
||||||
|
// Created by k0rb4k on 30/03/2021.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "quote.h"
|
||||||
|
|
||||||
|
void getRandomQuote(char quote[1024]) {
|
||||||
|
// TODO: true random between 0 and number of lines in file
|
||||||
|
int rand = 0;
|
||||||
|
getQuote(rand, quote);
|
||||||
|
}
|
||||||
|
|
||||||
|
void getQuote(int line, char quote[1024]) {
|
||||||
|
FILE* list;
|
||||||
|
// char quote[1024];
|
||||||
|
|
||||||
|
// TODO: get specified x line
|
||||||
|
|
||||||
|
list = fopen("quotes.txt", "r");
|
||||||
|
|
||||||
|
fgets(quote, 1024, list);
|
||||||
|
|
||||||
|
fclose(list);
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
//
|
||||||
|
// Created by k0rb4k on 30/03/2021.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef QOTD_QUOTE_H
|
||||||
|
#define QOTD_QUOTE_H
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <bits/types/FILE.h>
|
||||||
|
#include <bits/types/struct_FILE.h>
|
||||||
|
|
||||||
|
void getRandomQuote(char quote[1024]);
|
||||||
|
|
||||||
|
void getQuote(int line, char quote[1024]);
|
||||||
|
|
||||||
|
#endif //QOTD_QUOTE_H
|
||||||
Reference in New Issue
Block a user