What is the best way to handle an output struct with some strings in it ?
struct info
{
wchar_t * text;
size_t text_len;
}
void Foo(struct info * output);
User need to allocate text himself
output can be recycled in a loop
hard to know how much memory needs to be allocated, possible waste of memory if output is to be stored (eg...
Where does glibc get its database of unicode attributes, for such functions as eg, wcwidth()? I'm interested in correcting a few errant entries, but I can't seem to find where this information is in its source distribution.
If it matters, I'm primarily interested in this under debian or ubuntu linux.
...
Hi, Could somebody please explain what GCC is doing for this piece of code? What is it initializing? The original code is:
#include <stdio.h>
int main()
{
}
And it was translated to:
.file "test1.c"
.def ___main; .scl 2; .type 32; .endef
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
...
My platform is windows vista 32, with visual c++ express 2008 .
for example:
if i have a file contains 4000 bytes, can i have 4 threads read from the file at same time? and each thread access a different section of the file.
thread 1 read 0-999, thread 2 read 1000 - 2999, etc.
please give a example in C language.
...
Using vc++ compiler how one can access serial port. Bioscom() function can be used in Turbo C.
...
we have to work with RL-RTX (RTOS) in our project.in that we have to do some web pages.we have experience in building web pages in linux using "go-ahead webserver".
can we code in c language and store that executable in .cgi extension and call from the browser?
please tell us.
...
Hi all,
I wrote some code recently (ISO/ANSI C), and was surprised at the poor performance it achieved. Long story short, it turned out that the culprit was the floor() function. Not only it was slow, but it did not vectorize (with Intel compiler, aka ICL).
Here are some benchmarks for performing floor for all cells in a 2D matrix:
VC...
int main()
{
int var = 0;; // Typo which compiles just fine
}
...
I've run into a little theoretical problem. In a piece of code I'm maintaining there's a set of macros like
#define MAX_OF_2(a, b) (a) > (b) ? (a) : (b)
#define MAX_OF_3(a, b, c) MAX_OF_2(MAX_OF_2(a, b), c)
#define MAX_OF_4(a, b, c, d) MAX_OF_2(MAX_OF_3(a, b, c), d)
...etc up to MAX_OF_8
What I'd like to do is replace them wi...
A bit of background first. My company is evaluating whether or not we will migrate our Informix database to Oracle 10g. We have several ESQL/C programs. I've run some through the Oracle Migration workbench and have been muddling through some testing. Now I've come to realize a few things.
First, we have dynamic sql statements that are n...
I'm working on a library that must compile on linux and mac os X. Until now, I had no problem, compiling with "-g" worked well under both OS.
I tried to compile with some optimization ("-O2") and it works well under linux but I get an Undefined Symbol when I try to link a program with my library under mac os X.
Does anyone have any clu...
I'm working on an old school linux variant (QNX to be exact) and need a way to grab a web page (no cookies or login, the target URL is just a text file) using nothing but sockets and arrays.
Anyone got a snippet for this?
note: I don't control the server and I've got very little to work with besides what is already on the box (adding i...
When should I use messages versus C-style functions?
...
Is there an existing Linux/POSIX C/C++ library or example code for how to rebind a socket from one physical interface to another?
For example, I have ping transmitting on a socket that is associated with a physical connection A and I want to rebind that socket to physical connection B and have the ping packets continue being sent and re...
Hi,
if I have an array of pointers like char **lines, how can i determine its length?
Thanks
...
So this code has the off-by-one error:
void foo (const char * str) {
char buffer[64];
strncpy(buffer, str, sizeof(buffer));
buffer[sizeof(buffer)] = '\0';
printf("whoa: %s", buffer);
}
What can malicious attackers do if she figured out how the function foo() works?
Basically, to what kind of security potential pr...
How do I create a string so that it formats floating point numbers to have no trailing decimal point or digits when it is an integer, but to NOT switch to scientific notation for larger numbers?
When I do:
float myFloat= 15.6f;
float myInt = 5.0f;
float myLarge = 7000000.0f;
sprintf(out, "my float is %g", myFloat);
...
This code is supposed to send a string to the clipboard. However I got it to work once. Now it does not come up correctly when I CTRL+V.
But when I use this snippet to identify the clipboard text it shows what it should be.
#include <windows.h>
#include <iostream>
BOOL SetClipboardText(LPCTSTR pszText)
{
BOOL ok = FALSE;
if(O...
I have a need for a fixed-size (selectable at run-time when creating it, not compile-time) circular buffer which can hold objects of any type and it needs to be very high performance. I don't think there will be resource contention issues since, although it's in a multi-tasking embedded environment, it's a co-operative one so the tasks t...
Ok, here goes. I've completed a Cocoa foundation-tool that calculates mean absolute deviation of random integers (Just as a learning project).
I've moved the calculation into a function called "findMeanAbsoluteDeviation()" It accepts a NSMutableArray of NSNumber objects to preform calculations. Anyways. So this works all fine and dandy...