I am attempting to make the following call,
PID = pthread_create(&t, NULL, schedule_sync(sch,t1), NULL);
schedule_sync returns a value, I would like to be able to grab that value, but from what Ive read about pthread_create, you should pass a "void" function. Is it possible to get the return value of schedule_sync, or am I going to ha...
I'm writing a few very tight loops and the outermost loop will run for over a month. It's my understanding that the less local variables a function has, the better the compiler can optimize it. In one of the loops, I need a few flags, only one of which is used at a time. If you were the proverbial homicidal maniac that knows where I liv...
I thought I read about a C standard library function recently that was able to return a pointer to any extern variable whose name was passed to it as a const char *. I think that it works via linker symbols, if that helps.
...
I'm writing a function that gets passed a pointer to an array of length 4. This array will contain integers 0 <= x <= 52 and I would like to construct an array of length 48 with every integer from da kine that's not in the passed in array. In python this would be
# just included for specificity
cards = [card for card in deck if card not...
I apologize if this question is a little broad. Hopefully your answers will help me narrow it down to more meaningful questions.
I'm experienced in software engineering and had a recent conversation with a friend who suggested that electrical engineering is very software driven these days.
I'm trying to improve my understanding of th...
Whats the difference between a Null pointer & a Void pointer?
...
how ro resolve this error in Linux system with GCC compiler........
...
On a linux box
is it compulsory to write a program into a file and compile it
cant this be done from command line
localhost$gcc "include<stdio.h> int main(){printf('hello world'); return o; }"
...
Does Linux provide an exception handling in C without resorting to C++? Or, what might be the best way to implement such an exception handling? The goal is to avoid to check return codes for every function called, but do something like in C++ that is thread safe and easily portable.
...
I have a thread that sits in a blocking recv() loop and I want to terminate (assume this can't be changed to select() or any other asynchronous approach).
I also have a signal handler that catches SIGINT and theoretically it should make recv() return with error and errno set to EINTR.
But it doesn't, which I assume has something to do ...
I'm writing a C project in Eclipse and while trying to run it I get the following error message:
(Cannot run program "make": Launching failed)
My Makefile is:
all : GenericHashTable.o TableErrorHandle.o
gcc -Wall GenericHashTable.o TableErrorHandle.o -o all
GenericHashTable.o : GenericHashTable.c GenericHashTable.h TableError...
This is my code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>
char test[];
size_t write_data(char *ptr, size_t size, size_t nmemb, FILE *stream)
{
char buf[size*nmemb+1];
char * pbuf = &buf[0];
memset(buf, '\0', size*nmemb+1);...
I used to think the second argument for inet_ntop should always be a struct in_addr or struct in6_addr. But then I looked up the POSIX definition:
const char *inet_ntop(int af, const void *restrict src,
char *restrict dst, socklen_t size);
[...] The src argument points to a buffer holding an IPv4 address if th...
Hi,
How can we call "C++" class member functions in 'C" code ?
I have two files .cpp, in which I have defined some classes with member functions and corresponding ".h" files which has included some other helping cpp/h files.
Now I want to call these functionality of CPP files in "C" file.
How can I do it.
Thanks
Priyanshu
...
Hello I'd like to list all real users on Linux/*nix and it's data. I probably need to parse /etc/passwd and /etc/shadow and check if user have password.
The problem is that is not cross-platform (on *BSD there is no /etc/shadow). Is there any cross-platform library/command I can use?
...
I am using getdomainname() and gethostbyname() to try to get the domain of the computer so I can show the correct information on my program. However sometimes these functions don't return the correct information.
Is there any other way (in plain C) to get the domain name in Linux?
Edit: just to make it a bit more clear: I want to check...
Why do the functions displayed in a callstack generated in Solaris always contain 6 parameters?
In most of the cases, the original function will not be having 6 parameters at all. Sometimes I also find, the parameter values displayed are not matching the order in function declaration.
Any pointers or links for understanding these conc...
Hello,
How do i define a 2D array using malloc ? (lets say 10X20).
second, can i increase number of rows or cols without creating a new increased array and copying all data to it?
for instance, how do i allocate memory so the array will be 10x30 or 15x20?
thank!
...
Hello,
I'm trying to define a path at compile time by passing:
-DDCROOTDEF='"/path/to/stuff"'
on the compile line. I then try to get use this in the code like:
char * ptr_path;
strcpy(ptr_path, DCROOTDEF);
strcat(ptr_path,"/MainCommons/CommonLib/fonts/Arial.ttf");
char *pftf=ptr_path;
gdImageStringFT(pimg,brect,iclr,pftf,pts,ang,i...
Given
struct S {
SomeType single_element_in_the_struct;
};
Is it always true that
sizeof(struct S) == sizeof(SomeType)
Or it may be implementation dependent?
...