it compiles
Este cometimento está contido em:
cometimento
5340cd4ef2
1
.gitignore
externo
Ficheiro normal
1
.gitignore
externo
Ficheiro normal
@ -0,0 +1 @@
|
||||
efn
|
||||
4
c_quit.c
Ficheiro normal
4
c_quit.c
Ficheiro normal
@ -0,0 +1,4 @@
|
||||
void
|
||||
c_quit() {
|
||||
exit(0);
|
||||
}
|
||||
3
commands.c
Ficheiro normal
3
commands.c
Ficheiro normal
@ -0,0 +1,3 @@
|
||||
void (*commands[256])() = {
|
||||
NULL,
|
||||
['q'] = c_quit,
|
||||
2
compile.sh
Ficheiro executável
2
compile.sh
Ficheiro executável
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
gcc efn.c -o efn
|
||||
1
consts.h
Ficheiro normal
1
consts.h
Ficheiro normal
@ -0,0 +1 @@
|
||||
#define ROW_SIZE 100
|
||||
15
efn.c
Ficheiro normal
15
efn.c
Ficheiro normal
@ -0,0 +1,15 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "consts.h"
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include "efn.h"
|
||||
|
||||
#include "main.c"
|
||||
|
||||
#include "commands.c"
|
||||
};
|
||||
|
||||
#include "c_quit.c"
|
||||
|
||||
4
efn.h
Ficheiro normal
4
efn.h
Ficheiro normal
@ -0,0 +1,4 @@
|
||||
extern void (*commands[256])();
|
||||
|
||||
void c_quit();
|
||||
|
||||
11
main.c
Ficheiro normal
11
main.c
Ficheiro normal
@ -0,0 +1,11 @@
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
static char buf[256];
|
||||
while (1) {
|
||||
char *com = fgets(buf, sizeof(buf), stdin);
|
||||
if (com != NULL) {
|
||||
commands[com[0]]();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
2
types.h
Ficheiro normal
2
types.h
Ficheiro normal
@ -0,0 +1,2 @@
|
||||
typedef struct Row Row;
|
||||
struct Row {Row *p; Row *n; char text[ROW_SIZE]; int line;};
|
||||
Carregando…
x
Criar uma nova questão referindo esta
Bloquear um utilizador