Sorry if the question isn't clear; I found it pretty hard to explain in one sentence.
Say I have a struct with a member which is a struct, e.g. the following:
struct A {
struct B b;
};
Lets say I intend instances of this structure to be heap-allocated always. Is there anything to be gained by changing it to this? (i.e. keeping a ...
I'm trying to parse some strings from a web page but I keep getting strings that happen to be broken up with no way to check if the string is complete or not. At the moment, I have a buffer of 1024 bytes that I'm receiving parts of the page with. What should I do to make sure I get the full string, preferably without an overly large buff...
I am programming an mp3 application, and I have it so it starts on start up. However when looking at it in msconfig it says manufacturer is unknown. How can I make it say "daxsoft"?
Is there a a way to do this without a .rc file?
...
I've literally spent the past half hour searching for the solution to this, and everything involves GCC. What I do here works absolutely fine with GCC, however I'm using TinyCC, and this is where I'm getting confused. First the code:
#include <Python.h>
#include <stdio.h>
int main(int argc, char*argv[])
{
Py_Initialize();
PyRun_...
I have a few very large log files, and I need to parse them. Ease of implementation obviously points me to Perl and regex combo (in which I am a still novice). But what about speed? Will it be faster to implement it in C? Each log file is in the order of 2 GB.
...
I'm testing the timing of an algorithm that does lots of recursive calls. My program dies at about 128k recursive calls, and this takes only .05 seconds. I'd like to allow more memory to have longer timings in my analysis. I'm running linux and using gcc. Is there a system call, or environment variable, or gcc flag, or wrapper, or someth...
I want to implement ping request in C language.I am working on Windows platform.Can any one suggest how to implement it or if code is already available then from where i can find it?
...
I make the following reasoning, please tell me what's wrong (or right) about it:
"If inlining a function duplicates the code in the place the function is called, then the static and local variables are duplicated for each function calling it and if there is only one thread running the function that calls the inlined one at the same time...
I was wondering if there was a better way of handling the case in C where you want to exit a function as soon as you encounter an error in a series of expressions. (in this case, its a function that returns a NULL on error)
e.g. in some C code where they tried to short circuit error handling by combining a series of statements with AND...
I can't use boost:hash because I have to stick with C and can't use C++.
But, I need to hash a large number (10K to 100k) of tokens strings (5 to 40 bytes length) so that search within those are fastest.
MD5, SHA1 or any long hash function seems too heavy for a simple task, I am not doing cryptography. Plus there is the storage and com...
I'm running a sort of "sandbox" in C on Ubuntu: it takes a program, and runs it safely under the user nobody (and intercepts signals, etc). Also, it assigns memory and time limits, and measures time and memory usage.
(In case you're curious, it's for a sort of "online judge" to mark programs on test data)
Currently I've adapted the safe...
When using inline assembly under MSVC, one is allowed to jump outside of the assembly block by referencing a label in the C/C++ code, as explained in this MSDN article.
Can such thing be done when using inline assembly under GCC?
Here's an example of what I'm trying to accomplish:
__asm__ __volatile__ (
" /* assembly code */ "
" j...
I'm trying to learn C and I've come across something weird:
struct
{
int i;
double j;
} x, y;
struct
{
int i;
double j;
} z;
Here, you can see I created two structs that are identical in their elements.
Why is it that when I try to assign x = z it will generate a compile error but x = y does not? They have the same contents...
I've asked a similar question on structs here but I'm trying to figure out how C handles things like assigning variables and why it isn't allowed to assign them to eachother if they are functionally the same.
Lets say I have two arrays:
int x[10];
int y[10];
Why won't x = y compile? If they are both the same "signature" like that,...
I want to make sure my string ends with ".foo". I am using C, a language I am not totally familiar with. The best way I have found to do it is below. Any C gurus want to make sure I'm doing this elegantly and wisely?
int EndsWithFoo(char *str)
{
if(strlen(str) >= strlen(".foo"))
{
if(!strcmp(str + strlen(str) - strlen...
So, I'm writing a text editor, using MDI.
I have a frame window, child windows and each child window has a text-area window.
Now, my problem is the pointer. It's not setting itself to the correct bitmap. So for example, if I move the pointer to the border, it correctly turns into the left-right drag icon. That's all good and well - ...
What is the maximum size of buffers memcpy and other functions can handle? Is this implementation dependent? Is this restricted by the size(size_t) passed in as an argument?
...
I have the following C code:
struct myStruct_t
{
const char m_name[60];
const uint32_t m_data;
};
const struct myStruct_t myStruct
__attribute__(( __aligned__( 64 ), section(".init") )) =
{
"myName",
(uint32_t)&someOtherStruct
};
When I compile in gcc 4.1.1 (for PS3), I get the warning:
1>c:/t...
Does anyone know of a great small open source Unicode handling library for C or C++? I've looked at ICU, but it seems way too big.
I need the library to support:
all the normal encodings
normalization
finding character types - finding if a character should be allowed in identifiers and comments
validation - recognizing nonsense
...
I'm working on a project on an 8051 where every byte counts. As such, I am using some global variables where I normally wouldn't. The normal method of passing pointers into a function adds too much overhead here.
I have a number of functions that use single bit variables (a compiler specific extension to C) to signal the outcome of a ...