The program below is written in C and creates a structure that holds the values of a text editor. This structure is beneficial during the development of text editor applications. Let me know if you find the code below helpful and if you have any additional suggestions:
/*-----------------------------------------------------------
* Description: Program that creates a text editor struct
*-----------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXSIZE 100
typedef enum {false, true} bool;
typedef struct textnode textnode_t;
struct textnode {
char thechars[MAXSIZE+1]; //storage for characters
bool newpara; //true if this starts a new paragraph,false otherwise
textnode_t *next; // pointer to sturct textnode
int char_size; // size of the chars
int newpar_pos; // new paragraph position
};
struct text{
textnode_t *first; // points to the first node in the list
unsigned length; // holds total length of text
};