c

Is there a tool that enables me to insert one line of code into all functions and methods in a C++-source file?

It should turn this int Yada (int yada) { return yada; } into this int Yada (int yada) { SOME_HEIDEGGER_QUOTE; return yada; } but for all (or at least a big bunch of) syntactically legal C/C++ - function and method constructs. Maybe you've heard of some Perl library that will allow me to perform these kinds of operations...

pointer to an array

Hi, I have a pointer to an array and i am unable to access the members of the array.To make it more precise,plz see the code below: int struc[2] = {6,7}; int (*Myval)[2]; Myval =&struc; Now the Myval is pointing to the start of the array and upon dereferencing the pointer we would get the 1st element o...

size_t,key_t,time_t etc

i have encountered these "X_t" types many times in c programs,what does they really mean?where is the location of these definition? ...

How to Write a Windows Application?

I'm very new to programming, and I'd like to write a Windows Application. So far I've read Teach Yourself C in 24 Hours, what should I do (tutorial to read) next to accomplish my goal? Thanks ...

C/C++ an int value that isn't a number ?!

Can this ever happen ? 3 asserts, where one should activate. int nr = perform_calc(); assert( nr == 0); assert( nr > 0); assert( nr < 0); Can there be a case when the program doesn't activate the asserts on g++ 3.4.4. And no I don't have the possibility to change the code in order to print the number out in case the asserts don't act...

Steps to make a LED on or off from a C program using Serial Port?

Hi gusys, I knew there is a similar post: http://stackoverflow.com/questions/209603/steps-to-make-a-led-blink-from-a-c-c-program But now I am working on a arm-based development board, and it seems to have two serial ports that I could use it to make a LED on or off. Basically I think the flow is , make one pin in serial "1" or on and ...

What does crypt() do in C?

crypt(text,"k7") I looked it up and apparently 'k7' is the salt, but I have no idea what that means nor what type of output will come from that, anyone know? ...

Initializing array of pointers to char

When I try to compile the following code I receive an error: "Type error in argument 1 to 'allocate'; found 'char * *', expected 'char *" at the line indicated (<<<<<). Explanations would be appreciated. #include <stdio.h> #include <string.h> void allocate(char *dt); int main(void) { char *data[3]; allocate(data); <<<<< retu...

How to add two numbers without using ++ or + or another arithmetic operator.

How to add two numbers without using ++ or + or any other arithmetic operator. It was a question asked a long time ago in some campus-interview. Anyways today someone asked a question regarding some bit-manipulations, and in answers a beautiful quide *stanford Bit Twiddling * was referred. I spend some time studying it, and thought that ...

Please recommend resources for experienced developer new to C

I'm looking for good websites, and possibly books, to help me improve my C (not C++). I've been coding for over 10 years, mainly in Java, but my experience of C is minimal. I don't need something that explains what an 'if' statement does, I'm more interested in best-practices, and common pitfalls, with an emphasis on the things likely to...

Tool for converting C header files (.h) to VB?

I can see that there are tools for converting .h to Python, Perl, D, Pascal etc. Are there any for VB6 or any other VB-alike tool (like Jabaco for instance)? ...

Compile the Python interpreter statically?

I'm building a special-purpose embedded Python interpreter and want to avoid having dependencies on dynamic libraries so I want to compile the interpreter with static libs instead (eg libc.a not libc.so). I would also like to statically link all dynamic libraries that are part of the Python standard library as well. I know this can be ...

Can you write to a byte array using a FILE*

C# has a neat feature of being able to write to a memory stream using the MemoryStream object. I'm looking for similar functionality from C using a FILE* pointer. I want to be able to sprintf() but with the added functionality of having C remember "where I was" in the buffer I'm writing to. ...

UNIX nonblocking I/O: O_NONBLOCK vs. FIONBIO

In every example and discussion I run across in the context of BSD socket programming, it seems that the recommended way to set a file descriptor to nonblocking I/O mode is using the flag to fcntl(), e.g. int flags = fcntl(fd, F_GETFL, 0); fcntl(fd, F_SETFL, flags | O_NONBLOCK); I've been doing network programming in UNIX for over te...

Is it ok to use "classic" malloc()/free() in Objective-C/iPhone apps?

I've been playing around with iPhone development for a while, and although it feels a bit awkward when you're a "hard core" .NET developer, it's not all that bad once you get used to it. In every book I read about Objective-C, there's only talk about retain/release (reference counting) for memory management. As an old-skool C/C++ develo...

Why doesn't C terminate strings with a special escaped string-termination character?

In C, strings are terminated with null ( \0 ) which causes problems when you want to put a null in a strings. Why not have a special escaped character such as \$ or something? I am fully aware at how dumb this question is, but I was curious. ...

Evaluating mathematical expressions

I am looking for an algorithm that I can use to evaluate mathematical expressions. I've seen a few questions on SO that are simmilar but the answers are C#/Delphi or python specific. I need to write the algorithm in C :) The problem I am trying to solve is given a user input like 3*(2*x + 1)/x I can evaluate the expression for any v...

Declaring function parameters after function name

int func(x) int x; { ............. What is this kind of declaration called? When is it valid/invalid including C or C++, certain standard revisions and compilers? ...

Delete a Line from a file in C Language

Hey, I want to delete certain lines in a file and insert certain lines in the same file based on whether certain parts of the line match a specified string. Is there a way of doing this without using a temporary file to copy the contents to and so on? Thanks Gitmo ...

Emacs Psychotherapist: Where can I find the code?

Hi I'd like to port the Emacs Psychotherapist to C :) but I would like to know where I can find the source code. What I am afraid of is that it is written in Lisp. If it is I think I will be out of luck porting it to C unless someone has already done it. Any pointers would be appreciated (pun not intended!) ...