I have a header file where a few functions needs to be implemented in the header file and included in a main.c file to be tested. These are some library functions of String and encoding.
Once these methods are implemented in the header file I should be able to include this file in another c file and execute these methods.
#ifndef ABSTRING_H
#define ABSTRING_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#define ABSBLOCK 4096
typedef struct _abstring
{
unsigned char* val;
size_t length;
size_t space;
}absval;
abstring absval;
//Initialize string
abstring* initAbs() {
printf("%s", abval.val);
printf("%zu", abval.val);
abval.length = sizeof(abval.val);
abval.space = ABSBLOCK - sizeof(abval.val);
return &abval;
}
------------------ End of the header file (abString.h ) ------------------------
main.c file
#include "abString.h"
int main()
{
abstring absinit;
absinit.val = "abString";
printf("ABSBLOCK block size : %d .\n", ABSBLOCK);
initAbs();
return 0;
}
The issue I'm having is once I define a val in the main c file I'm not able to retrieve that value inside my header file in order to initialize the length and space.