The JSimple library provides a set of utility functions for common tasks. Below, you'll find a description of each function and how to use it.
The Print
function is used to print a string to the console.
String
: The string to be printed.
Print("Hello, World!");
The GetInput
function is used to read a line of text input from the user.
- A string containing the user's input.
string userInput = GetInput();
The CreateInput
function displays a prompt and reads a line of text input from the user.
prompt
: The prompt to display to the user.
- A string containing the user's input.
string userInput = CreateInput("Enter your name: ");
The ReadFileToList
function reads the contents of a file line by line and stores them in a vector of strings.
filepath
: The path to the file to be read.
- A vector of strings, where each element represents a line from the file.
vector<string> lines = ReadFileToList("myfile.txt");
The ReadFileToString
function reads the entire contents of a file and returns them as a single string.
filepath
: The path to the file to be read.
- A string containing the contents of the file.
string fileContents = ReadFileToString("myfile.txt");
The WriteToFile
function writes data to a file.
filename
: The name of the file to write to.data
: The data to be written to the file.
vector<int> numbers = {1, 2, 3, 4, 5}; WriteToFile("output.txt", numbers);
The StringListToString
function concatenates a vector of strings into a single string.
stringList
: A vector of strings to be concatenated.
- A single string containing the concatenated contents of the vector.
vector<string> words = {"Hello", "World"}; string result = StringListToString(words);
The RandomFloat
function generates a random floating-point number between min
and max
.
min
: The minimum value of the random number.max
: The maximum value of the random number.
- A random floating-point number.
float randomValue = RandomFloat(0.0f, 1.0f);
The RandomInt
function generates a random integer between min
and max
.
min
: The minimum value of the random number.max
: The maximum value of the random number.
- A random integer.
int randomNumber = RandomInt(1, 100);
The ToLowerCase
function converts a string to lowercase.
string
: The string to be converted.
- A new string with all characters in lowercase.
string text = "Hello World"; string lowercaseText = ToLowerCase(text);
The ToUpperCase
function converts a string to uppercase.
string
: The string to be converted.
- A new string with all characters in uppercase.
string text = "Hello World"; string uppercaseText = ToUpperCase(text);
The ReverseString
function returns the Input string but reversed character wise.
Input
: The string to be reversed.
- A new string with all characters reversed.
string text = "Hello World"; string reversedString = ReverseString(text);
The ToWideString
function converts the string into a wide string.
Input
: The string to be converted.
- A new wide string.
string text = "Hello World"; wstring WideString = ToWideString(text);
The IsPrime
function checks if a number is a prime.
Number
: The string to be checked.
- True if the number is a prime or false if not.
int Number = 1; bool IsPrime = IsPrime(number);