start quote selection implementation
This commit is contained in:
parent
7d0d4356dc
commit
296059e911
@ -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)
|
||||||
24
quote.c
Normal file
24
quote.c
Normal file
@ -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);
|
||||||
|
}
|
||||||
16
quote.h
Normal file
16
quote.h
Normal file
@ -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
|
||||||
Loading…
Reference in New Issue
Block a user