This repository has been archived on 2023-04-18. You can view files and clone it, but cannot push or open issues or pull requests.
iaj/TP1/Prolog/AidesCPP/3.cpp

24 lines
534 B
C++
Raw Normal View History

2023-02-01 10:10:53 +01:00
#include <SWI-cpp.h>
2023-02-01 10:19:02 +01:00
#include <cstdio>
2023-02-01 10:10:53 +01:00
// swipl-ld -ld g++ -goal true 3.cpp empty.pl
// on retire 3-f.pl de la compile pour le charger à chq execution
2023-02-01 10:19:02 +01:00
// charger empty.pl (qui est vide) permet de ne pas avoir le message de bienvenu
// de Prolog
2023-02-01 10:10:53 +01:00
2023-02-01 10:19:02 +01:00
int main(int _ac, char **_av) {
2023-02-01 10:10:53 +01:00
PL_initialise(_ac, _av);
PlTermv pl_args(1);
pl_args[0] = "3-f.pl";
PlCall("consult", pl_args);
PlTermv pl_args2(1);
PlQuery q0("f", pl_args2);
2023-02-01 10:19:02 +01:00
while (q0.next_solution()) {
2023-02-01 10:10:53 +01:00
printf("---> %s\n", (char *)pl_args2[0]);
}
return 0;
}