Hi everyone, this is somewhat of an odd question.
I wrote a C function. Its 'like' strchr / strrchr. It's supposed to look for a character in a c-string, but going backwards, and return a pointer to it. As c strings are not "null initiated", it also takes a third parameter 'count', indicating the number of chars it should look backwards...
When designing a C API for configuring a library/utility, I have a co-worker who prefers to lump all configuration parameters into 1 function call. For example:
int set_diagnostic_email_config( char *to_address,
bool include_timestamp,
bool send_for_crashes,
...
Hi,
I am currently watching an XML file from log4j output. I have a custom viewer that displays the log-output in GUI. I need to watch this file as to when it gets updated so that the GUI can re-parse and update itself. In C# there is a FileWatcher concept so on Windows no-probs, but what options do i have using C on Linux.
Is there a ...
I have an array a[i][j]. The elements are char, interpreted as subsets of the set {1,...,8} (the element k is in the subset if the k-th bit is 1). I do not think it is relevant, but every element has exactly 4 bits set.
Every row a[1][j]..a[n][j] is a collection of subsets of {1,...,8}. I need to remove duplicate rows, where two rows ar...
I've a question about the memory management in C (and GCC 4.3.3 under Debian GNU/Linux).
According to the C Programming Language Book by K&R, (chap. 7.8.5), when I free a pointer and then dereference it, is an error. But I've some doubts since I've noted that sometimes, as in the source I've pasted below, the compiler (?) seems to work...
I'd like to do a search for simple if statements in a collection of C source files.
These are statements of the form:
if (condition)
statement;
Any amount of white space or other sequences (e.g. "} else ") might appear on the same line before the if. Comments may appear between the "if (condition)" and "statement;".
I want to ex...
I try to measure the clock cyles needed to execute a piece of code on the TMS32064x+ DSP that comes with the OMAP ZOOM 3430 MDK. I look at the "Programmer's Guide" of the DSP chip and it says that the DSP supports the clock() function.
What I do is really simple, I just do
start = clock();
for (i=0;i<100;i++){
/* do something here ...
I want to profile my execution in a non-standard way. Using gprof, Valgrind, Oprofile... for a given function, I only get the mean of its execution time. What I would like is to obtain the standard deviation of this execution time.
Example:
void a()
sleep ( rand() % 10 + 10 )
void b()
sleep ( rand() % 14 + 2 )
main
for (1 .. 10...
This is something that's I've wanted to know recently, mostly out of curiousity. I'm in the mood to learn some old coding styles, and FORTRAN seems like a good place to start.
I guess I should help you guys out by providing a good starting point.
So how would this C procedure be written in FORTRAN?
int foo ( int x , int y )
{
int...
Hi,
I had just written a programme which reverses a sentence whatever the user gives.
for eg:If the user gives the sentence as "How are you",my programm generates "uoy era woH".
The programme which i had written is shown below.I just have a wild intution that there can be a smarter programe than the one which i had written.So valuab...
Anyone knows of some good Unicode tutorials with examples in C? I have to create a console app (to be run in xterm), with Unicode support, and it has to be on C. :(
...
Hello. This is an ANSI C question. I have the following code.
#include <stdio.h>
#include <locale.h>
#include <wchar.h>
int main()
{
if (!setlocale(LC_CTYPE, "")) {
printf( "Can't set the specified locale! "
"Check LANG, LC_CTYPE, LC_ALL.\n");
return -1;
}
wint_t c;
while((c=getwc(stdin))!=...
Discussing with people, asking in interviews, or being asked in interviews, I do not know if I know exactly when to write a function as inline or write it as a macro. Apart from compile-time and run-time consideration, is there any suggestion from coding standard point of view.
I think this is one of those question where it comes to the...
I'm interested in unescaping text for example: '\' -> '\' in C. Anyone knows of a good library?
By html escape I mean, all the entity references.
...
I read somewhere that the ?: operator in C is slightly different in C++, that there's some source code that works differently in both languages. Unfortunately, I can't find the text anywhere. Does anyone know what this difference is?
...
Hi,
I have the very common problem of creating an index for an in-disk array of strings. In short, I need to store the position of each string in the in-disk representation. For example, a very naive solution would be an index array as follows:
uint64 idx[] = { 0, 20, 500, 1024, ..., 103434 };
Which says that the first string is at po...
I'm currently using a explicit cast to unsigned long long and using %llu to print it, but since size_t has the %z specifier, why clock_t doesn't have one? There isn't even a macro for it. Maybe I can assume that on a x64 system (OS and CPU) size_t has 8 byte in length (and even in this case, they have provided %z), but what about clock_t...
Hi,
For my source-code transforming (Fortran and C) numerical automatic differentiation engine project PARADE, I need a language-independent representation of procedural program code. The IL (intermediate language) in the below diagram:
(The whole tool will be developed solely using Haskell, so strip Java from the above diagram where...
I know that standard C doesn't give me any ability to do anything with folders, but I would like a fairly portable and cross-platform way to access folders. At this time, all I need to do is make a folder, check if a folder exists, and possibly delete a folder. I can forsee needing to read files from a folder in the near future, but that...
It is possible to move a .sqllite file somewhere while not corrupting it in C or C++?
Somewhere could be another folder or something.
If so could you give me some tips/pointers.
...