-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Version 1
- Loading branch information
Showing
4 changed files
with
247 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,44 @@ | ||
# easyc | ||
# Easy C | ||
![Version](https://img.shields.io/badge/version-v1.0.0-red) | ||
![Publisher](https://img.shields.io/badge/publisher-YasTech-blue) | ||
![Developer](https://img.shields.io/badge/developer-Hossein%20Araghi-white) | ||
### Navigation | ||
1. <a href="#what-is-easy-c">What is Easy C?</a> | ||
2. <a href="#why-we-should-use-easy-c">Why we should use Easy C?</a> | ||
3. <a href="#usage-of-easy-c">Usage of Easy C</a> | ||
4. <a href="#reference-of-easy-c">Reference of Easy C</a> | ||
5. <a href="#last-changes">Last changes</a> | ||
### What is Easy C? | ||
Easy C is c library base on CMake, and it contains many of functions and data types to make your code easy, fast and standard. You can simply use it in your project with CMake. | ||
### Why we should use Easy C? | ||
- Have a cleaner code | ||
- Make things easier | ||
- Do things standard | ||
- Faster and better app | ||
### Usage of Easy C | ||
- First clone library to your project | ||
- Second Add Library to your `CMakeLists.txt` | ||
```cmake | ||
# if you are using sub directories | ||
# add_subdirectory(lib/easyc) | ||
# add library to your project | ||
# put your project name instead of *main* | ||
target_link_libraries(main PRIVATE easyc) | ||
``` | ||
### Reference of Easy C | ||
| Name | Type | Description | Args | | ||
| --------------- | --------- | --------------------------------------- | ----------- | | ||
| string | data type | Replacement for characters | | | ||
| getString | function | Get a string input from the system | string q | | ||
| getInt | function | Get a string input from the system | string q | | ||
| getDouble | function | Get a double input from the system | string q | | ||
| getFloat | function | Get a float input from the system | string q | | ||
| getChar | function | Get a char input from the system | string q | | ||
| getLong | function | Get a long input from the system | string q | | ||
| print | function | print string without \n | string text | | ||
| println | function | print string with \n | string text | | ||
| intToString | function | convert int to string | int number | | ||
| copyToString | function | copy string to new string and return it | string text | | ||
| uppercaseChar | function | make character uppercase | char c | | ||
| uppercaseString | function | make string uppercase | string text | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
/* | ||
title : Easy C Library | ||
copyright : Copyright 2021 YasTech.org | All Right Reserved | ||
developer : Hossein Araghi | ||
url : https://yastech.org | ||
version : 1.0.0 | ||
*/ | ||
|
||
#include "easyc.h" | ||
|
||
// get string value | ||
string getString(string q) | ||
{ | ||
printf("%s", q); | ||
string a = NULL; | ||
scanf("%ms", &a); | ||
return a; | ||
} | ||
|
||
// get int value | ||
int getInt(string q) | ||
{ | ||
printf("%s", q); | ||
string str; | ||
string ptr; | ||
long a; | ||
scanf("%ms", &str); | ||
a = strtol(str, &ptr, 10); | ||
return (int) a; | ||
} | ||
|
||
// get double value | ||
double getDouble(string q) | ||
{ | ||
printf("%s", q); | ||
string str; | ||
string ptr; | ||
long a; | ||
scanf("%ms", &str); | ||
a = strtol(str, &ptr, 10); | ||
return (double) a; | ||
} | ||
|
||
// get float value | ||
float getFloat(string q) | ||
{ | ||
printf("%s", q); | ||
string str; | ||
string ptr; | ||
long a; | ||
scanf("%ms", &str); | ||
a = strtol(str, &ptr, 10); | ||
return (float) a; | ||
} | ||
|
||
// get char value | ||
char getChar(string q) | ||
{ | ||
printf("%s", q); | ||
char a; | ||
scanf("%c", &a); | ||
return a; | ||
} | ||
|
||
// get long value | ||
long getLong(string q) | ||
{ | ||
printf("%s", q); | ||
string str; | ||
string ptr; | ||
long a; | ||
scanf("%ms", &str); | ||
a = strtol(str, &ptr, 10); | ||
return a; | ||
} | ||
|
||
// usual print | ||
void print(string text) | ||
{ | ||
printf("%s", text); | ||
} | ||
|
||
// print with new line | ||
void println(string text) | ||
{ | ||
printf("%s\n", text); | ||
} | ||
|
||
// Convert Int To String | ||
string intToString(int number) | ||
{ | ||
string c = malloc(5); | ||
sprintf(c, "%d", number); | ||
return c; | ||
} | ||
|
||
// Convert Long To String | ||
/*string longToString(long number) | ||
{ | ||
string c = malloc(20); | ||
sprintf(c, "%d", number); | ||
return c; | ||
}*/ | ||
|
||
// Copy String | ||
string copyToString(string text) | ||
{ | ||
|
||
int length = (int) strlen(text); | ||
string copy = malloc(length + 1); | ||
for (int i = 0; i < length + 1; i++) | ||
{ | ||
copy[i] = text[i]; | ||
} | ||
return copy; | ||
} | ||
|
||
// Upper Case Letter | ||
char uppercaseChar(char c) | ||
{ | ||
if(c > 96 && c < 123) | ||
{ | ||
return (char) ((int) c - 32); | ||
} else | ||
{ | ||
return c; | ||
} | ||
} | ||
|
||
// Upper Case String | ||
string uppercaseString(string text) | ||
{ | ||
string output = malloc(strlen(text) + 1); | ||
for (int i = 0; i < strlen(text); i++) { | ||
if(text[i] > 96 && text[i] < 123) | ||
{ | ||
output[i] = (char) ((int) text[i] - 32); | ||
} else | ||
{ | ||
output[i] = text[i]; | ||
} | ||
} | ||
return output; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
title : Easy C Library | ||
copyright : Copyright 2021 YasTech.org | All Right Reserved | ||
developer : Hossein Araghi | ||
url : https://yastech.org | ||
version : 1.0.0 | ||
*/ | ||
|
||
#ifndef EASY_C_H | ||
#define EASY_C_H | ||
|
||
// Includes | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
// Define Type String | ||
typedef char* string; | ||
|
||
// get string value | ||
extern string getString(string q); | ||
|
||
// get int value | ||
extern int getInt(string q); | ||
|
||
// get double value | ||
extern double getDouble(string q); | ||
|
||
// get float value | ||
extern float getFloat(string q); | ||
|
||
// get char value | ||
extern char getChar(string q); | ||
|
||
// get long value | ||
extern long getLong(string q); | ||
|
||
// usual print | ||
extern void print(string text); | ||
|
||
// print with new line | ||
extern void println(string text); | ||
|
||
// Convert Int To String | ||
extern string intToString(int number); | ||
|
||
// Convert Long To String | ||
// extern string longToString(long number); | ||
|
||
// Copy String | ||
extern string copyToString(string text); | ||
|
||
// Upper Case Letter | ||
extern char uppercaseChar(char c); | ||
|
||
// Upper Case String | ||
extern string uppercaseString(string text); | ||
|
||
#endif //EASY_C_H |