Hello!
Here is function that i am writing on 64 bit linux machine.
void myfunc(unsigned char* arr) //array of 8 bytes is passed by reference
{
unsigned long a = 0; //8 bytes
unsigned char* LL = (unsigned char*) &a;
LL[0] = arr[6];
LL[1] = arr[3];
LL[2] = arr[1];
LL[3] = arr[7];
LL[4] = arr[5];
LL[5] = arr[4];
...
I want to move a large chunk of data i've got in my memory. Unfortunately this data is saved as an array, and i cannot change that. I can't use circular arrays, because the same memory is also used by a couple of fortran methods i do not want to change. On top of it, the arrays are accessed very very often in between the movement. So i c...
I'm trying to take the convolution of an array of data, 256x256, with a filter, 3x3 on a GPU using shared memory. I understand that I'm to break the array up in blocks, and then apply the filter within each block. This ultimately means that blocks with overlap along the edges, and some padding will need to be done around the edges where ...
Is it possible to change a process parent?
ex: parent A has Child B can I make the parent of B is the Init process without killing A?
...
Hi..
I can't seem to understand the difference between the different declarations on an array or a 2d array.
for instance:
void swap(char **a, char **b) {
char *t = *a;
*a = *b;
*b = t;
}
int main(int argc, char **argv) {
char a[] = "asher";
char b[] = "saban";
swap(&a,&b);
}
this code doesn't compile, it outp...
For a class assignment, we are writing a custom syscall which pulls certain information about the existing process tree. The syscall is working fine for the most part and gets the appropriate information. However, a few processes it, in crashes with the error message, "Unable to handle kernel NULL pointer dereference at virtual address...
Is it safe to convert an int pointer to void pointer and then back to int pointer?
main()
{
...
int *a = malloc(sizeof(int));
...
*a=10;
func(a);
...
}
void func(void *v)
{
int x=*(int *)v;
...
}
Is this a valid way of getting the integer value back in the function?
...
My embedded projects have a post-process step that replaces a value in the executable with the CRC of (some sections of) the flash. This step can only be done after linking since that is the first opportunity to CRC the image. In the past the file format was COFF, and I have created a custom tool to do the patching.
The development too...
I'd like to detect if Wake On Lan is possible.
On my router (Tomato firmware) there is a table with info - when displays device "Active (In ARP)" - it's possible to turn this device by WOL (offline linux pc).
I wonder if it is achieved by router only function or I can do this in C# or C? Function SendArp can detect MAC adress and do ...
I have created a user interface using GTK+ and C. I was wondering if there are any testing frameworks for testing this interface, similar to how selenium (a software testing framework for web applications) can be used for testing the interfaces of web applications. I want to create some regression tests for my GTK+ interface. Thanks!
...
Executive summary:
How can I define an arbitrarily-sized 2D array in C?
How can I determine the dimensions of that array at compile-time?
Full disclosure:
I'm writing code for an embedded controller. My application requires several lookup tables with different sizes which will all be used by one lookup function (a binary search). He...
We use Lua (www.lua.org) script to let users to customize our server software written in C++.
At the moment we are porting the 32 bits Windows version of our project to Visual Studio 2010.
Once everything works fine with VS 2008, we thought that we would have no problem on upgrade process.
Unfortunately whenever we tried to link the lu...
Consider the following code:
char* str = "Hello World";
memcpy(str, "Copy\0", 5);
A segmentation fault occurs during the memcpy. However, using this code:
char str[12];
memcpy(str, "Hello World\0", 12);
memcpy(str, "Copy\0", 5);
The program does not produce a segmentation fault.
Does the problem arise from allocating the memory on...
Is there a way to find out if the machine is 32-bit or 64-bit by writing some code in C?
...
I was wondering how to, using C, find out what port a client is currently listening to. ie, I want to know what the source port is, not the destination port.
Thanks in advance!
...
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
int main (int argc, const char * argv[])
{
printf("start\n");
char *const parmList[] = {"/bin/ls", "-l", NULL};
execv("/bin/ls", parmList);
return 0;
}
I compiled with GCC4.2 Any ideas why this might crash? I'm not getting any error messages in xcode.
EDIT: us...
Hi all,
I have a C function that writes some data to a text file. The data consists of floats, ints and strings.
it looks something like this:
writeAsTextFile( mystruct_t* myStructWithIntsFloatsAndStrings , const char* fileName);
for doing this I use calls to fprintf;
Now I would like to write the same data but as binary. I could...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
static char *dup_str(const char *s)
{
size_t n = strlen(s) + 1;
char *t = (char*) malloc(n);
if (t)
{
memcpy(t, s, n);
}
return t;
}
static char **get_all_files(const char *path)
{
DIR *dir;
struct dirent *dp;
c...
What is the proper way to name my revisions?
v1.0.3.20 Alpha
or
Alpha v1.0.3.20
...
int main()
{
int j=97;
char arr[4]="Abc";
printf(arr,j);
getch();
return 0;
}
this code gives me a stack overflow error why?
But if instead of printf(arr,j) we use printf(arr) then it prints Abc.
please tell me how printf works , means 1st argument is const char* type so how arr is
treated by compiler.
sorry! abo...