FILE *results;
int queen;
if (!(results = popen("./precosat -f nqueens.cnf | tail -n +2 | head -n -1 | tr -d v | tr ' ' '\n' | grep -v '^$' | grep ^[0-9]", "r"))) {
cout << "Unable to Execute Precosat" << endl << "./precosat -f nqueens.cnf | tail -n +2 | head -n -1 | tr -d v | tr ' ' '\n' | grep -v '^$' | grep ^[0-9]" << endl;
exit(1);
}
for (i = 0; i < queens; i++) {
fscanf(results,"%d",&queen);
cout << "Queen #" << i+1 << " goes to [" << ((queen%queens)?(queen%queens):queens) << "]" << endl;
}
pclose(results);
Above, you will find an example that was used to extract data from the PrecoSAT SAT Solver in order to solve the N-Queens problem. It returns all positive variables, one per line.
You can see that after the call to popen, it creates a pointer to a file stream that can be used as a regular file to read the data from the called process.
By downloading PrecoSAT from http://fmv.jku.at/precosat/ and trying to install it on Ubuntu 11.10 32-bit (Oneiric Ocelot) by: Decompressing the files and calling ./configure && make I got the following error at make: g++ -O3 -m32 -static -Wall -Wextra -DNDEBUG -DNLOGPRECO -DNSTATSPRECO -c precomain.cc In file included from precomain.cc:23:0: precosat.hh:164:31: error:…
When you try to print an unsigned 8-bit (1 byte - uint8_t) integer through cout, you will notice that instead of getting the arithmetic value of the variable on the output, you will get its character representation of the ASCII table. This issue occurs due to the fact that there…
Recently we tried to execute an application and we got the following error: -bash: ./main: No such file or directory This error occurred because our application was trying to use an interpreter that was not available on that machine. We used the readelf utility that displays information about ELF files…