-
Notifications
You must be signed in to change notification settings - Fork 4
/
file_input_output.h
51 lines (44 loc) · 1.29 KB
/
file_input_output.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// ============================
// = User Input Function in C =
// ============================
//
// This header file contains the types and functions/procedures
// in the Terminal User Input code. You can #include "terminal_user_input.h"
// to access these from your project. Remember to compile both your
// program file and the terminal_user_input.c file.
//
//
// The following code makes sure that you cant accidentally
// include this code twice. It is common to see this kind of
// code at the top of a C/C++ header file.
//
#ifndef FILE_INPUT_OUTPUT_H
#define FILE_INPUT_OUTPUT_H
#include <stdio.h>
#include "terminal_user_input.h"
//
// The my_string type can be used to represent a "string" in C.
// This needs to be a struct so that it can be returned from
// functions.
//
// typedef struct my_string
// {
// char str[256]; // my string contains an array of 255 characters + null
// } my_string;
//
// Reads a string of up to 255 characters + 1 for null
//
my_string file_read_string(const char* prompt);
//
// Reads a integer from the user.
//
int file_read_integer(const char* prompt);
//
// Reads a integer from the user in a given range.
//
int file_read_integer_range(const char* prompt, int min, int max);
//
// Reads a double from the user.
//
double file_read_double(const char* prompt);
#endif