Using printf with a non-null terminated string
Suppose you have a string which is NOT null terminated and you know its exact size, so how can you print that string with printf in C? I recall such method but I can not find out know... ...
Suppose you have a string which is NOT null terminated and you know its exact size, so how can you print that string with printf in C? I recall such method but I can not find out know... ...
Hi, I work extensively using the shell. When I continue working on some project one week later, I go to some "folder" and realize that I do not remember what I was doing. Sometimes and before stopping work what I do is: history > DIRX_HISTORY_20100922 so later I have a look at the commands I used, I can remember much better what I w...
I have a c program, that gets its settings from an XML file. Currently I'm using Xerces to traverse the data, but it's getting quite tedious to map each XML-value to a variable. The same XML is also read by a Java program, which is much more convenient due to JAXB creating all the necessary classes and such in Java. I'm looking for some...
i want to send a file using c in an adhoc network in mt linux platform...plz help me with the header files and functions that i need to use ...
Consider #include <cstdio> int main() { char a[10]; char *begin = &a[0]; char *end = &a[9]; int i = end - begin; printf("%i\n", i); getchar(); } #include <cstdio> int main() { int a[10]; int *begin = &a[0]; int *end = &a[9]; int i = end - begin; printf("%i\n", i); getchar(); } #...
I've declared many functions in one driver, and am passing the pointers to the functions to another driver in a list with the node format: struct node { char def_prototype[256]; //example:(int (*)(wchar, int, int)) void *def_function; }; Is there a way to typecast def_function to the prototype given in def_prototype? Currently I'm ...
Hello, I have an IP address stored in in_addr_t and I want to create the string representation of this data type, ie in_addr_t to 10.0.0.1. How can I do that? ...
Hi, I have a loop as follows while(1) { int i; } Does i get destroyed and recreated on the stack each time the loop occurs? ...
Hi All, I'm working on a high performance application where all calls must be justified. I have a map that is used once in the beginning of each transaction to do a lookup that I would like to improve upon. The map is loaded at startup and does not change after that. The key in the map below is an std::string but it can it changed ...
Suppose you have to related structures defined in 2 header files like below: a.h contents: #include b.h typedef struct A { B *b; } A; b.h contents: #include a.h typedef struct B { A *a; } B; In such this case, this recursive inclusion is a problem, but 2 structures must point to other structure, how to accomplish this? ...
I wish to profile CPU (sample if possible), with as small a performance impact as possible (hence similar to GCC's -pg), binaries compiled with Clang. Is there an alternative that uses instrumentation of the code, or produces output similar to gprof? ...
Hi all, After reading about VA_NARG I tried to implement function overloading depending on number of arguments in C using macros. Now the problem is: void hello1(char *s) { ... } void hello2(char *s, char *t) { ... } // PP_NARG(...) macro returns number of arguments :ref to link above // does not work #define hello(...) ...
Is there a command or any other way to get the current or average CPU utilization (for a multi-processor environment) in Linux? I am using embedded Linux in a small system. Basically, I need to determine the CPU utilization, so that if it is high, I can instead divert a new process to another controller in the system, rather than execut...
Hi there, I am not very familiar with winsock or network programming, so I hope you forgive me if I am asking stupid stuff :) I develop a client/server application which share some camera images. The general cycle is: The client captures a camera image and compress it to an binary image. After that it sends it to the server The serve...
I'm converting a header file for a DLL written in C to Delphi so I can use the DLL. My question is what is the difference between int* i and int *i I convert the first to i: PInteger; But i'm not sure what the correct conversion is for the second one in Delphi. from my understanding the first is a simple typed pointer. The se...
This code does not compile for me on gcc version 4.3.2 (Debian 4.3.2-1.1) main(){ int unix; } I've checked the C keywords list and "unix" is not one of them. Why am I getting the following error? unix.c:2: error: expected identifier or ‘(’ before numeric constant Anybody? ...
Is there any good tool to generate java (+JNI support if needed) from a header file so that a C or C++ library can be used as-is. Kind of a reverse of javah. The real functionality would be in the C/C++, the Java would be only a shim on top for certain users. I'm no expert on JNI but as far as I can see Javah forces you to do this back...
Is it posible to use the type of a prefiously declared function as a function pointer without using a typedef? function declaration: int myfunc(float); use the function declaration by some syntax as function pointer myfunc* ptrWithSameTypeAsMyFunc = 0; ...
Hi! I'm looking for a simple c/c++ lib that would allow to extract the first frame of a video as a uchar array. And have a simple fonction to access the next one. I know of FFMPEG but it requiere to play with packet and things like that, and i'm surprised that nowhere on the net i can find a lib that allow something like : Video v = o...
I'm implementing a sequential program for sorting like quicksort. I would like to test the performance of my program in a huge array of 1 or 10 billions of integers. But the problem is that I obtain a segmentation error due to the size of the array. A sample code of declaration of this array: #include <stdio.h> #include <stdlib.h> #inc...