hi.
I have C/C++ code, that looks like this:
static int function(double *I) {
int n = 0;
// more instructions, loops,
for (int i; ...; ++i)
n += fabs(I[i] > tolerance);
return n;
}
function(I); // return value is not used.
compiler inlines function, however it does not optimize out n manipulations.
I would ex...
Hello , can anyone tell my what does the #pragma can do in the c language . what are its uses and why the above program is not giving the output 'inside v1'& 'inside v2' in the following program ...
# include<stdio.h>
void v1();
void v2();
# pragma startup v1
# pragma exit v2
int main()
{
printf("inside main\n");
return 0;
}
void v1(...
So I'm serializing a C data structure for cross-platform use, and I want to make sure I'm recording my floating point numbers in a cross-platform manner.
I had been planning on just doing
char * pos;
/*...*/
*((double*) pos) = dataStructureInstance->fieldWithOfTypeDouble;
pos += sizeof(double);
But I wasn't sure that the bytes wo...
Was reading the response by Shaggy Frog to this post and was intrigued by the following line of code:
NSLog(@"%@", [NSString stringWithFormat:@"%@:%*s%5.2f", key, padding, " ", [object floatValue]]);
I know string formatting is an age old art but I'm kinda doing the end around into Cocoa/Obj-C programming and skipped a few grades alo...
Lets us consider the following program :
#include <stdlib.h>
int main(int argc, char **argv){
int a,b;
if (argc != 3)
return -1;
a = atoi(argv[1]);
b = atoi(argv[2]);
a = b ? a/b : 0;
return a;
}
The task is to crash the program by providing arguments in command-line.
...
Hi again. I've come to bother you all with another probably really simple C question.
Using the following code:
int get_len(char *string){
printf("len: %lu\n", strlen(string));
return 0;
}
int main(){
char *x = "test";
char y[4] = {'t','e','s','t'};
get_len(x); // len: 4
get_len(y); // len: 6
return 0;...
I am running an agentx master and an agentx subagent on linux. When I run snmpget on a
default MIB i.e. sysdescr.0 it returns fine, but when I request for a MIB that was registered through the agentx subagent it timesout. It appears that the master receives the GET request but does not forward on to the agentx subagent. The MIB is regis...
I am working on a Augmented reality Project where I plan to use ARToolkit for Image Capturing and rendering where as ARToolKitPlus for marker detection.
The problem is ARToolKit is a C library where as ARToolKit+ is written in C++. Can some one please sugegst me a way to integrate them both.
ARToolKit Library
ARToolkitPlus
...
I am just making sure I understand this concept correctly. With the * operator, I make a new variable, which is allocated a place in memory. So as to not unnecessarily duplicate variables and their values, the & operator is used in passing values to methods and such and it actually points to the original instance of the variable, as oppo...
Hi...Imagine that i have on a txt this:
Hello
SLB
3
1324
how can i get the 3rd line? fgets or fscanf?
and imagine on a txt this:
8;9;10;12
how can i print the numbers separeted?
...
function(char* name)
{
char sql[50];
sprintf(sql, "select %s;", name);
}
What's the best way to make sure only 50 chars of name are copied to sql in the case name is larger than what sql can hold? (sprintf with a N parameter?)
Thank You.
...
I was wondering how hard disk access works. Ex, how could I view/modify sectors? Im targeting Windows if that helps.
Thanks
...
Okay, so if I'm running in a child thread on linux (using pthreads if that matters), and I run the following command
kill(getpid(), someSignal);
it will send the given signal to the parent of the current thread.
My question: Is it guaranteed that the parent will then immediately get the CPU and process the signal (killing the app if ...
Suppose I have the following struct and function returning a pointer:
typedef struct {
int num;
void *nums;
int size;
} Mystruct;
Mystruct *mystruct(int num, int size)
{
//Is the following correct? Is there a more efficient way?
Mystruct mystruct;
mystruct.num = num;
mystruct.size = size;
mystruct.nums = malloc(nu...
What direction should I go in(libraries, documents)?
UPDATE
Can someone illustrate how to use winpcap to do the job?
UPDATE 2
How do I verify whether a packet is an HTTP one?
...
LEA EAX, [EAX]
I encountered this instruction in a binary compiled with the Microsoft C compiler. It clearly can't change the value of EAX. Then why is it there at all?
...
How to access block level storage via the kernel (w/o using scsi libraries)?
My intent is to implement a block level storage protocol over network for learning purpose, almost the same way SCSI works. Requests will be generated by initiator and sent to target (both userspace program) which makes call to kernel module and returns the ...
Hi all,
I have some fairly generic code which uses preprocessor macros to add a certain prefix onto other macros. This is a much simplified example of what happens:
#define MY_VAR(x) prefix_##x
"prefix_" is actually defined elsewhere, so it will be different each time the file is included. It works well, but now I have some code I ...
A normal routine of sqlite3_prepare_v2() + sqlite3_step() + sqlite3_finalize() could contain leak.
It sound ridiculous. But the test code seems to say it. Or I used the sqlite3_*() wrongly.
Appreciate for any reply.
#include <stdio.h>
#include <unistd.h> // for usleep()
#include <sqlite3.h>
int multi_write (int j);
sqlite...
fprintf(file, "%d %d %d", array[0], array[1], array[2]);
for this statement to work i have to open the file in 'wb' mode rather than 'w' mode . How does a binary mode make the syntax work?
...