No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.
This below code is the code minimized of real code. Is posible synchronize a global variable with pthread and main while(1)? On the below code, the printf not apper in order and delayed of the 1 second. #include <pthread.h> #include <stdio.h> pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; int teste; void *ThreadFunc(void *arg) … |
|
I need know what is the size of a address of one variable, in other words, how much bytes I need to store the address of a variable (in compilation time). Unhappily not is possible use sizeof in define pre-processors, like this: [CODE] #define ADDRESS_SIZE sizeof(void *) [/CODE] So, I … |
|
Hello Everybody. I'm with a classic problem in C preprocessor concatenation. This is the situation: [CODE] #define BAUDRATE(VAL) (B ## VAL) //... const uint32_t BAUDRATE_VAL[] = {1200, 2400, 9600}; //... br = BAUDRATE(BAUDRATE_VAL[i]); //... [/CODE] This code, result in the error: BBAUDRATE_VAL undeclared I need that the result of concatenation … |
|
I have this: [B]foo(cons char *p);[/B] foo not is my function, and I don't have access to your source code. I'm trying use foo so: [B]char val[32]; foo(val);[/B] The result of foo is zero and not the desired string. Other tries: This work: [B]foo("something here");[/B] This don't work: [B]foo((cons char … |
|
Is necessary deallocate memory of pointer-to-pointer? Example: [CODE] my_type_t **example; example = (my_type_t **) calloc(10, sizeof(my_type_t *)); for (i = 0; i < 10; i++) { example[i] = (my_type_t *) malloc(sizeof(my_type_t)); } // ... free(example); // it enough? // Or is necessary do this... for (i = 0; i < … |
|
Hello, I'm with difficult in this situation: [CODE] void teste(int *p_int) { printf("&p_int = %li\n", (long int) &p_int); // Line T1 printf("p_int = %li\n", (long int) p_int); // Line T2 p_int = malloc(sizeof(int)); (*p_int) = 123; printf("*p_int = %li\n", (long int) *p_int); // Line T3 } int main(void) { int … |