Hi,
I'm seeing some weird behaviour when using wordexp() in a minimal C program when started within Xcode. I cannot reproduce this by starting the compiled binary from the command line.
#include <stdio.h>
#include <stdlib.h>
#include <wordexp.h>
#include <errno.h>
#include <assert.h>
int main (int argc, const char * argv[])
{
int ...
I wonder what languages are used in robots and electronics. Is it low level languages like Java, C, C++ etc?
And if these robots and electronics could be controlled from another place, what protocol is used?
It couldn't be HTTP Rest, could it? :)
...
Hello,
gcc 4.4.4 c89
I have the following code and 2 structures that have to be filled.
I have 3 functions that will fill the handles for each of the devices.
However, the device_type structure will need to increment from where the last function finished.
For example:
load_resources() starts at 0 and finishes at 9
dev_types sta...
Basically the problem comes down to this:
I load a file, write all the each character into a char* variable which has malloc() the length of the file. Then I return that variable and print it, then I free() the memory for that variable and try to print the variable again which does print it.
I'm very new to C so there is probably som...
A struct like the following works fine, I can use t after calling malloc(sizeof(mystruct)):
struct mystruct {
MyDef *t[5];
};
I want to be able to dynamically set the length of the array of MyDef, like the following:
struct mystruct {
MyDef **t;
int size;
};
What do I need to do additionally to malloc(sizeof(mystruct)) to get th...
I want to have a C preprocessor macro that knows the number of instantiations/macro calls of this macro so far.
Example:
int main() {
printf("%d\n", MACRO());
printf("%d\n", MACRO());
}
Should print
0
1
Is something like this possible?
Note that it is not enough to forward this to a function as proposed below.
It should work i...
Possible Duplicate:
How to printf unsigned long in C?
I have my number like so...
int unsigned long number = 600851475143;
I am trying to print it with printf(). Every time I try, I get a warning by the compiler.
I've tried %uld, %ld and Googling hasn't seemed to find me the answer.
I'm learning C, but have not had to us...
Hello all,
I have a macro that I use to `goto', I want to let the macro know about the label.
Example:
#define MYMACRO((a),(b)) printf("I have arg: %s, %s with Label: %s at line %d", (a), (b), _GETLABEL_, __line__)
mylabel: MYMACRO("a1","a2")
This should print:
I have arg: a1, a2 with Label: mylabel at line 4
Is it possible to ...
H!
I have source in C, which is use the connect(peer->fd, (struct sockaddr *)dst->sockaddr, sizeof(struct sockaddr_in)); C method. I use the NDK and make the jni.
My application is a msrp modul, which contain a server and a client. This method is part of the client.
The source fragment:
/* We're going to be the client, connect to the...
EDIT: Updated code with new Pastebin link but it's still stopping at the info->citizens[x]->name while loop. Added realloc to loops and tidied up the code. Any more comments would be greatly appreciated
I'm having a few problems with memory allocation overflowing
http://pastebin.com/vukRGkq9 (v2)
No matter what I try, simply not enoug...
Which open source implementations of a tree (with arbitrary number of children per node; nodes containing a small data type like int or a pointer (additional to the implementation-specific indexing data, of course)) in a (linear) buffer do exist? (Obviously, the maximum number of tree nodes is bounded by the buffer size)
(Graph instead ...
My library offers a callback point where my library users can register to get information. The general form of the callback is an int followed by various parameters whose type depend on the int value. Therefore, I defined the callback type and the function to set it as follows.
typedef void (* callback_func_t)(int type, ...);
void set_c...
I have reduced the problem to the following basic function which should simply print the
number of bytes in the file.
When I execute it for a file of 83886080 bytes (80 MB) it prints the correct number.
However for a file of 4815060992 bytes (4.48 GB) it prints 520093696 which is way to low.
It seems to have something to do with the SE...
In this homework, two matrices should be added using a different thread for each quadrant. This is my attempt so far, it generates a seg fault that I haven't been able to identify.
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#define N 4 //matrix dimension
int c[4][4];
int a[4][4]={1 ,3, 4, 5, 3, 4, 5, 6,7, 8, 9, 0, 2, 1...
I have a very simple c programme:
int main()
{
return(1);
}
and a simple Makefile:
all:
gcc -ansi -pedantic -o tmp tmp.c
./tmp
However, when I type make I get the following error message:
$ make
gcc -ansi -pedantic -o tmp tmp.c
./tmp
make: *** [all] Error 1
What obvious thing am I missing?
...
int main ()
{
struct bit{
char f1:1;
char f2:1;
};
struct bit b;
b.f1= 0x1;
b.f2 = 0x1;
printf("%d\n",b.f1);
return 0;
}
compiled using gcc the code outputs -1. Should it not be 1? Is it because I am compiling on a little endian machine?
Added:While debugging using GDB i see that the value after initializi...
Is there any way to optimize the following line of C code (to avoid branching)?
if ((i < -threshold) || (i > threshold))
{
counter++;
}
All variables are 16-bit signed integers. An optimized version should be highly portable.
...
Hello,
I am looking at building an application with heavy ties to git..
Are there language bindings available and if so which are the most comprehensive?
Would it mean going to Bare Metal C?
Or does perl python php C# have a set of full bindings?
Thanks
Daniel
...
Hi!
I have a big question. There are an application, which contain the following method:
socket(AF_INET, SOCK_STREAM, 0);
The socket return 29 and I don't see the port in the terminal (netstat).
I use this method in Android-ndk and I use the INTERNET permission in the Android Manifest file.
What is the problem in the method?
Thanks
...