I have an array of arbitrary values, so I have defined it as an array of void pointers, so I can point to any kind of information (like int, character arrays, etc). However, how do I actually assign an int to it?
Take for example these initializations:
void* data[10];
int x = 100;
My intuition would think this, but this gives a compi...
Hi,
I've recently implemented some vectored exception handling to catch errors in our software. This is especially useful as we've just converted from vc6 to vs2005. We're encountering a few problems with the use of the STL library (generally people doing things they shouldn't). I'm trying to catch these errors with my vectored exceptio...
Say I have a struct like the following ...
typedef struct {
int WheelCount;
double MaxSpeed;
} Vehicle;
... and I have a global variable of this type (I'm well aware of the pitfalls of globals, this is for an embedded system, which I didn't design, and for which they're an unfortunate but necessary evil.) Is it faster to access t...
I want to implement a basic search/replace translation table in C; that is, it will read in a list of pairs of words from a config file, and go through a text received at runtime, replacing each source word it finds with the corresponding target word. For example, if my user-input text was
"Hello world, how are you today?"
and my conf...
char *loadTextFile(const char *filename)
{
FILE *fileh;
char *text = 0;
long filelength;
if((fileh=fopen(filename,"rb"))== 0)
printf("loadTextFile() - could not open file");
else
{
fseek(fileh, 0, SEEK_END);
filelength = ftell(fileh);
rewind(fileh);
text=(char *) smartmalloc...
Hi,
I am beginning to question the usefulness of "extern" keyword which is used to access variables/functions in other modules(in other files). Aren't we doing the same thing when we are using #include preprocessor to import function/variables definitions?
EDIT:
Maybe I should add this to the question:
... using # include preprocessor ...
I have an application. I have the source code (in C). I can compile it anyway I want. Add whatever tool I want to it. Etc. However, I do not want to pepper the source code with a bunch of printf's. I want to be able to produce a log of some sort that shows when a particular value (some member of a global structure for example) is written...
How can I make a fast dictonary ( String => Pointer and Int => Pointer ) in C without a linear search? I need a few ( or more ) lines of code, not a library, and it must be possible to use it in closed-source software (LGPL, ...).
...
Would like to fopen() the latest file in a directory
(with naming scheme file1.txt, file2.txt, file3.txt, etc.)
Is there an API function in Visual Studio for this?
If not, is it a good idea to read in all the .txt file names and sort to get the one I need? Is there a better algorithm I could be pointed to?
Thanks.
...
Hello,
Doing regex in C# or PHP is very easy for me now. However currently I have a need to use regex in C. And, I don't seem to understand the usage of regcomp or regexec fully. It's definitely because of my lack of experience in C.
Any help and examples would be much appreciated!
...
int is usually 32 bits, but in the standard, int is not guaranteed to have a constant width. So if we want a 32 bit int we include stdint.h and use int32_t.
Is there an equivalent for this for floats? I realize it's a bit more complicated with floats since they aren't stored in a homogeneous fashion, i.e. sign, exponent, significand. ...
Given a file (e.g. myfile.txt) with this content (always three lines):
0 2 5 9 10 12
0 1 0 2 4 1 2 3 4 2 1 4
2 3 3 -1 4 4 -3 1 2 2 6 1
How can we parse the file, such that it is stored
in arrays, just as if they were hard coded this way:
int Line1[] = { 0, 2, 5, 9, 10, 12 };
int Line2[] = { 0, 1, 0, 2, 4, 1, 2, 3, 4, 2, 1, ...
A friend of mine was trying to test me on C (my strongest language is C++) and he asked me three questions which I could not answer:
Try to explain the following declarations:
1) int (*x)(int, char *, void *);
2) int (*x[10])(int, char *, void *);
3) int (**x[10])(int, char *, void *);
Can anyone explain these function declarations a...
This is a simple code that open and print the file content.
#include <stdio.h>
#include <stdlib.h>
int main ( int arg_count, char *arg_vec[] ) {
int ch;
FILE * fp;
int i;
if (arg_count <2) {
printf("Usage: %s filename\n", arg_vec[0]);
exit(1);
}
if ((fp = fopen(arg_vec[1], "r")) == NULL) { // ...
Hi,
has anyone succeed in compiling/porting/finding the GNU scientific libraries for the SPU?
IF not, do similar libraries or wrappers for the SPU exist? or, how would you just port some of the functions?
Thanks
...
I'm looking for a way to get the tooltip control (if any) which is associated with a given HWND. The text of the tooltip control would be sufficient, too. The closest thing I found is the TTM_GETTEXT message, but it's meant to be sent to the tooltip control itself instead of the tool it's associated with. I don't have a handle to the too...
Hi,
I am curious to know what happens when the stack and the heap collide. If anybody has encountered this, please could they explain the scenario.
Thanks in advance.
...
I have a problem running the below code , which invokes getutent() to count the total number of users currently logged in to the system. The timer will be invoked every 1sec and will set the boolean named "isSigAlrmOccured" to true and exit.The main function checks whether the timer signal is delivered by checking this boolen and monitor...
Hello!
I want to compile C code from the Command Prompt in Windows. I have added the environment variable to the PATH and I can compile .cs files with: csc app.cs
That's OK, but how do I compile app.c?
...
When ddd encounters a scanf statement, it displays "Waiting until GDB gets ready" message. The debugging activity stops here. Please guide me of overcoming this bug.
I'm using an amd64 athlon processor.
...