string-type.h
Go to the documentation of this file.
1 
9 #ifndef _STRING_TYPE_H_
10 #define _STRING_TYPE_H_
11 
12 #include <stdlib.h>
13 
20 typedef struct String {
22  char* str;
24  unsigned int length;
26  unsigned int availableLength;
27 } String;
28 
35 String strInit(char* str);
36 
43 unsigned int strLength(String* str);
44 
50 void strPush(String* str, char c);
51 
57 void strPushStr(String* str, char* str2);
58 
65 char* strDuplicate(char* str);
66 
67 #endif // _STRING_TYPE_H_
unsigned int length
The current string length (number of characters in the string)
Definition: string-type.h:24
char * str
The normal, nul terminated char array that represents the string.
Definition: string-type.h:22
unsigned int availableLength
Size of the bloc allocated.
Definition: string-type.h:26
struct String String
Dynamic string handler.
void strPush(String *str, char c)
Adds a character at the end of the string.
Definition: string-type.c:30
String strInit(char *str)
Transforms a char* to a string. The char* MUST be a nul terminated array allocated with malloc...
Definition: string-type.c:10
char * strDuplicate(char *str)
Create a perfect copy of the string given. Used when a malloc created string is needed.
Definition: string-type.c:67
unsigned int strLength(String *str)
Returns the current string length.
Definition: string-type.c:26
Dynamic string handler.
Definition: string-type.h:20
void strPushStr(String *str, char *str2)
Add a string at the end of the current string.
Definition: string-type.c:42