It seems that GMP provides only string serialization of the mpf (floating point) type:
mpf_get_str(), mpf_class::get_str()
The mpz (integer) type has an additional interface for raw bytes: mpz_out_raw()
http://gmplib.org/manual/Function-Index.html
Am I missing something? Does anyone know of another library that can serialize GMP flo...
I have a Motif-based notepad-like legacy application.
I would like the modeless "Find/Replace" dialog (which is a Motif TopLevelShell) to always stay on top of the other windows of my application, but not on top of other applications.
I don't see any Motif-specific setting to do this.
KDE allows me to set window-specific behavior, but ...
Hi, I just want to ask, is there any special C standard for MCU? I ask because so far when I programmed something under Windows OS, it doesn´t matter which compiler I used. If I had compiler for C99 I knew what I can do with it.
But recently I started to program in C microcontrollers, and I was shocked, that even its still C in its bas...
Hi, I was writing a console application that would try to "guess" a number by trial and error, it worked fine and all but it left me wondering about a certain part that I wrote absentmindedly,
The code is:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int x,i,a,cc;
for(;;){
scanf("%d",&x);
a=50;
i=100/a;
for(...
Inside a large loop, I currently have a statement similar to
if (ptr == NULL || ptr->calculate() > 5)
{do something}
where ptr is an object pointer set before the loop and never changed.
I would like to avoid comparing ptr to NULL in every iteration of the loop. (The current final program does that, right?) A simple solution woul...
The clock_t implications in time.h released with Turbo C++ v1.01 are good only up to 0.0545XX seconds, meaning any timing I want to do with higher precision is impossible with that library.
I was wondering if anyone knew a good library or method available to elder TurboC++ that I could use instead of time.h calls for better precision?
...
When I run the following command from a makefile on 64-bit Red Hat Enterprise Linux 5.0 using GCC 4.2.3:
gcc -c -ansi -pedantic -O0 -fPIC -I. -I.. -Iheader_files/include "source_file.c"
I get the following error:
cc1: error: unrecognized command line option "-lang-c"
Superficially, the problem is that "-lang-c" is no longer a valid...
I salute you, StackOverflow gurus ;)
I'm trying to parse socket info from /proc/net/tcp and while I can identify some fields, such as memory addresses or send queue use, I can't find how each entry is bound to its socket descriptor. E.g., with this data:
1: 5922140A:E459 D5C43B45:0050 01 00000000:00000000 00:00000000 00000000 1000 ...
I was trying some process operations like fork()ing and exec()ing I tried this Example which in it the parent wait()s his child to return and test if his child ended normally (by exit()ing or return to his caller) or abnormally (receiving Signal like SIGABRT)
#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<unistd.h>
...
Sizeof() doesn't work when applied to bitfields:
# cat p.c
#include<stdio.h>
int main( int argc, char **argv )
{
struct { unsigned int bitfield : 3; } s;
fprintf( stdout, "size=%d\n", sizeof(s.bitfield) );
}
# gcc p.c -o p
p.c: In function ‘main’:
p.c:5: error: ‘sizeof’ applied to a bit-field
...obviously, since it...
I have a question in allocation of memory for static variables. Please look at the following snippet.
#include<stdio.h>
#include<conio.h>
void fun();
static int a;
void main()
{
fun();
getch();
}
void fun()
{
static int b;
}
Can someone please explain me when memory will be allocated for static int b in function fun (b...
I am looking to learn open GL, I have a strong foundation of the maths behind graphics. What is the best route to take in learning the Open GL technology i'm open to using both Windows and Mac.
Thanks in advance
...
I wrote up a quick memory reader class that emulates the same functions as fread and fscanf.
Basically, I used memcpy and increased an internal pointer to read the data like fread, but I have a fscanf_s call. I used sscanf_s, except that doesn't tell me how many bytes it read out of the data.
Is there a way to tell how many bytes ssc...
An implementation of a brute-force algorithm to solve Sudoku puzzles fails if a cell is discovered in which placing any of the digits 1-9 would be an illegal move.
The implementation is written in C, with the board represented by a 9x9 array. The solver counts down from 9 until a legal number's reached, and if none can be reached, it ou...
I have a program which embeds both python2 and python3 interpreters. The libpython shared libraries are dlopen()ed by the respective commands which provide access to the interpreters and each interpreter maintains its own state.
This all works just fine if the user only uses pure python modules or builtins. Trying to load a C extensio...
Is there any way to make this code shorter?
long call_f(int argc, long *argv) {
switch (argc) {
case 0:
return f();
break;
case 1:
return f(argv[0]);
break;
case 2:
return f(argv[0], argv[1]);
break;
case 3:
return f(argv[0], argv[1], argv[2]);
break;
case 4:
re...
in PHP, I have something like
function doStuff($in, $value)
{
$var = "V_" . $in;
$$var = $value;
}
Is there a way to do something similar in C?
Basically I'm trying to figure out how to make a sort of library to make working with IO pins on an AVR easier. So for example, there would be a function to set a particular pin ...
When I compile C code with my cross toolchain, the linker prints pages of warnings saying that my executable uses hard floats but my libc uses soft floats. What's the difference?
...
Basically I set up a test to see which method is the fastest way to get data from another computer my network for a server with only a few clients(10 at max, 1 at min).
I tried two methods, both were done in a thread/per client fashion, and looped the read 10000 times. I timed the loop from the creation of the threads to the joining of ...
If my application runs out of memory, I would like to re-run it with changed parameters. I have various malloc-s/new-s in various parts of the application, the sizes of which are not known in advance. I see two options:
Track all memory allocations and write a restarting procedure which deallocates all before re-running with changed pa...