Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/seff34/data-converter-in-c
Data Converter In C
https://github.com/seff34/data-converter-in-c
c cpp data-conversion data-converter dataconversion dataconverter embedded-c embedded-linux embedded-systems
Last synced: 1 day ago
JSON representation
Data Converter In C
- Host: GitHub
- URL: https://github.com/seff34/data-converter-in-c
- Owner: seff34
- Created: 2022-08-22T20:45:04.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2023-02-28T05:58:15.000Z (over 1 year ago)
- Last Synced: 2023-10-16T18:35:16.685Z (about 1 year ago)
- Topics: c, cpp, data-conversion, data-converter, dataconversion, dataconverter, embedded-c, embedded-linux, embedded-systems
- Language: C
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Data Convertor in C
Big Data to Low Data in C Standart Libs.
## Functions
#### Data Structure
```c
typedef struct{
uint8_t byte0;
uint8_t byte1;
uint8_t byte2;
uint8_t byte3;
} data32_t;
```#### Data Converter
```c
int8_t dataConverter32(int32_t input, data32_t *output);
```| Parameter | Type | Description |
| :-------- | :------- | :------------------------- |
| `input` | `int32_t` | Input Value|
| `output` | `data_t` | Output Value|#### Example Code
```c
int main(int argc, char **argv)
{
if ( argc != 2)
{
printf("Enter a integer\n");
return EXIT_FAILURE;
}int32_t data = atoi(argv[1]);
data32_t *parse;
if ((parse = (data32_t *)calloc(1,sizeof(data32_t))) == NULL)
{
perror("Memory allocate error\n");
return EXIT_FAILURE;
}dataConverter32((int32_t)data, parse);
printf("Byte 0 -> %d\n", parse->byte0);
printf("Byte 1 -> %d\n", parse->byte1);
printf("Byte 2 -> %d\n", parse->byte2);
printf("Byte 3 -> %d\n", parse->byte3);free(parse);
return EXIT_SUCCESS;
}
```## Download Code
Clone Project
```bash
git clone https://github.com/seff34/Data-Converter-In-C
```