Anonymous user
Execute a Markov algorithm: Difference between revisions
→{{header|C}}
m (→{{header|Scala}}: nitpick) |
|||
Line 179:
<lang c>#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h> // requires C99
#include <string.h>
#include <assert.h>
Line 187:
typedef struct rulestruct {
const char *trigger;
const char *replacement;
bool terminal;
struct rulestruct *next;
Line 268:
int bi;
rule_t *r;
char
const char *p, *bp;
bool repldone;
size_t s;
Line 287 ⟶ 288:
s = p - bp;
memcpy(d, bp, s);
strcpy(d,
d += strlen(r->replacement);
strcpy(d, bp + strlen(r->trigger) + s);
if ( r->terminal ) {
repldone = false;
Line 305 ⟶ 308:
}
int main(
{
FILE *rulefile_h = NULL;
|