From 660491eab18fb88b71d20b22c1a9e45c50fb8103 Mon Sep 17 00:00:00 2001 From: Hossein Araghi Date: Sun, 15 Aug 2021 00:07:40 +0430 Subject: [PATCH] Fix Project Dir Bug --- src/easyc.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/easyc.h | 59 +++++++++++++++++++++ 2 files changed, 203 insertions(+) create mode 100755 src/easyc.c create mode 100755 src/easyc.h diff --git a/src/easyc.c b/src/easyc.c new file mode 100755 index 0000000..65a23d0 --- /dev/null +++ b/src/easyc.c @@ -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; +} diff --git a/src/easyc.h b/src/easyc.h new file mode 100755 index 0000000..1021b51 --- /dev/null +++ b/src/easyc.h @@ -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 +#include +#include + +// 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