I am writing an application which has an authenticity mechanism, using HMAC-sha1, plus a CBC-blowfish pass over the data for good measure. This requires 2 keys and one ivec.
I have looked at Crypto++ but the documentation is very poor (for example the HMAC documentation). So I am going oldschool and use Openssl. Whats the best way to g...
Even I used break() and exit() statements many times, I am bit confused between them. I need to know exact meaning of both, when we should use them. Please explain with small example.
Thank you.
...
what is a good hashtable implementation for C? I need to use it with mpicc compiler. Delete function is not necessary.
...
How can I make a program that opens a text file, and converts it into a XML file?
The XML might look like:
<curso>
<sigla>LTCGM</sigla>
<NAlunos>1</NAlunos>
<lista_alunos>
<aluno>
<numero>6567</numero>
<nome>Artur Pereira Ribeiro</nome>
<email>[email protected]</email>
<estado>Aprovado</estado>
<media_notas>13</med...
Why does the following program segfault?
int main() { main(); }
Even though it is a recursion that does not end and is therefore invalid by definition, I don't see why it segfaults (gcc 4.4.3 and clang 1.5 (trunk)).
...
Code I:
for(i=0; i<100; i++){
for(j=0; j<1000; j++){
x = y;
}
}
Code II:
for(i=0; i<1000; i++){
for(j=0; j<100; j++){
x = y;
}
}
Can you explain why one of these loop configurations will take more time to run than the other?
...
For my university process I'm simulating a process called random sequential adsorption.
One of the things I have to do involves randomly depositing squares (which cannot overlap) onto a lattice until there is no more room left, repeating the process several times in order to find the average 'jamming' coverage %.
Basically I'm performi...
Hi,
I'm trying to develop a simple "telnet/server" daemon which have to run a program on a new socket connection.
This part working fine.
But I have to associate my new process to a pty, because this process have some terminal capabilities (like a readline).
The code I've developped is (where socketfd is the new socket file descriptor...
I've got to modify a C program and I need to include a set of unsigned integer sets. That is, I have millions of sets of integers (each of these integer sets contains between 3 and 100 integers), and I need to store these in some structure, lets call it the directory, that can in logarithmic time tell me whether a given integer set alre...
I am writing a program that reads the data from the serial port on Linux.
The data are sent by another device with the following frame format:
|start | Command | Data | CRC | End |
|0x02 | 0x41 | (0-127 octets) | | 0x03|
----------------------------------------------------
The Data field contains 127 octet...
I'm trying to cast a struct into another struct but I'm having incompatible pointer issues within the cast and the malloc under some_func (structs layout are the same)
struct stu1 **some_func(struct stu1 *my_struct)
{
my_struct = (struct stu1 **)malloc(sizeof(struct stu1 *)*total_size);
for(i=0;i<20;i++){
my_struct[i] = (st...
I have simple Haxe app like
class Main
{
public static function main()
{
trace("hello world");
}
}
I know how to compile such app for windows (not as SWF but as app from pure C\C++ )(and you can see how here but be worned thay use hxcpp\0,4 ) The problem is - I do not want to compile app for Windows Vista or 7 or XP I want to get PUR...
Hi,
i load a transparent .png into an UIImage.
How to i calculte the real bounding-box. E.g. if the the real image is smaller than the .png-dimensions.
Thanks for helping
...
I've been racking my brains on this for a while, I'm simply trying to create a method that returns a struct as I wish to return two int's.
My prototype for the method is as follows:
typedef struct RollDice();
Also the method itself:
typedef struct RollDice()
{
diceData diceRoll;
diceRoll.dice1 = 0;
diceRoll.dice2 = 0;
return d...
Is it safe to read directory entries via readdir() or scandir() while files are being created/deleted in this directory? Should I prefer one over the other?
EDIT: When I say "safe" I mean entries returned by these functions are valid and can be operated without crushing the program.
Thanks.
...
The following code outputs "Illegal seek":
#include <stdio.h>
#include <errno.h>
#include <string.h>
int main() {
errno = 0;
getchar();
getchar();
getchar();
ftell( stdin );
printf( "%s\n", strerror(errno) );
}
This occurs when I run "cat script | ./a.out" as well as when I just run "./a.out". The problem is...
When I declare a enum variable like this:
enum paint_colors { RED, GREEN, BLUE, ...} colors;
is the colors variable useful? If so, what can I do with it?
Thanks in advance.
...
I have committed to learning C now, I'm good with Python/PHP/Bash but I've decided I'm limited by not being fluent in C. However I cannot imagine working in a language without lists and hashes, maybe I'm just jumping a gun, but surely there are 'standard' collection libraries. I do not see any in the GNU standard lib though, any sugges...
This code fills a tree with values based on their depths. But when traversing the tree, I cannot manage to determine the actual number of children without iterating over the parent node. This is necessary because the subleafs are stored in in the node underneath the current one. Which conceptual changes are necessary to store the leafs d...
Hi guys, I want to do a Token concatenation, but I want to do this with the content of a variable, not its name. like this.
#define call_function(fun, number) fun##_##number ()
while (i < 10 ) {
call_function(fun, i);
}
but I give fun_number (), I want to give fun_1, fun_2, and so on...
how to do it?
About function pointers.
I'...