c

Why use c strings in c++?

Is there any good reason to use C-strings in C++ nowadays? My textbook uses them in examples at some points, and I really feel like it would be easier just to use a std::string. ...

Getting a FILE* from a std::fstream

Is there a (cross-platform) way to get a C FILE* handle from a C++ std::fstream ? The reason I ask is because my C++ library accepts fstreams and in one particular function I'd like to use a C library that accepts a FILE*. ...

C pointer assignment behavior

temp2, temp1 are pointers to some struct x: struct FunkyStruct x; struct FunkyStruct *temp1 = &x, *temp2 = &x; Now, after execution of following lines: temp2=temp1; temp1=temp1->nxt; ...Will temp2 and temp1 still point to the same memory location? If not, please explain why they would be different. ...

curses API

Where can I find a complete reference of the ncurses C API? ...

Which to go with long term - C, Objective C, or C++?

One thing I've really been meaning to get back into is C++ programming but I am not sure if I should go back to C++ (which I have some basic console programming knowledge) or should I look into C or Objective C? I'm looking at the long term as well as ease of coding such as good editors, compilers, etc as well as which would be the quick...

What coding techniques do you use for optimising C programs?

Some years ago I was on a panel that was interviewing candidates for a relatively senior embedded C programmer position. One of the standard questions that I asked was about optimisation techniques. I was quite surprised that some of the candidates didn't have answers. So, in the interests of putting together a list for posterity - wha...

Learning C, C++ or Delphi ?

I have been developing for about 8 years, and mainly come from a Web Background. I have extensively used the .Net Framework for development the last 5 odd years, including Web, Windows and Mobile. I have a good understanding of C# and VB, VB.Net I am thinking of learning a new language, and based on the interest I have understanding how...

Is there a printf converter to print in binary format?

I can print with printf as a hex or octal number. Is there a format tag to print as binary, or arbitrary base? I am running gcc. printf("%d %x %o\n", 10, 10, 10); //prints "10 A 12\n" print("%b\n", 10); // prints "%b\n" ...

C101: the best way to fill an array from user input?

I'm having a hard time understanding and therefore managing arrays and indexes manually in C. These are my two classic approaches but they doesn't seem to work as they keep looping when the condition is reached: #include<stdio.h> #define MAX 255 int main(){ int arr[MAX]={0}; int idx=0; /* Approach #1 */ printf("Ente...

MD5 routines that are GLib friendly?

Does anyone know of an MD5/SHA1/etc routine that is easily used with GLib (i.e. you can give it a GIOChannel, etc)? ...

How do you determine the size of a file (in C) for files that are larger than 4GB?

The code currently does this and the fgetpos does handle files larger than 4GB but the seek returns an error, so any idea how to seek to the end of a file >4GB? fpos_t currentpos; sok=fseek(fp,0,SEEK_END); assert(sok==0,"Seek error!"); fgetpos(fp,&currentpos); m_filesize=currentpos; ...

How to read a barcode from an image

I'm seeking a library, technique or advice on how to read an EAN-13 barcode from an image (including ISBN,and ISSN encodings). The image would come from a mobile phone or webcam, so resolution may be quite poor and not well aligned. I'm specifically interested in something that could be used from ruby on rails, but answers for other lan...

Platform Builder command line building question

I'm building a project from command line , using WinCE platform builder , and I need RTTI to be enabled , so that my project works correctly . I tried setting the option RTTI="YES" in the sources and in the makefile of each dir , and I also tried to add it at the end of CDEFINES , but when I try to build the project , I get the D9025 w...

How do I get the current size of a matrix stack in OpenGL?

How do I get the current size of a matrix stack (GL_MODELVIEW, GL_PROJECTION, GL_TEXTURE) in OpenGL? I want this so that I can do some error checking to ensure that in certain parts of the code I can check that the matrix stacks have been left in the original condition. ...

What is the best unicode library for C?

What is the best unicode library for C? Where "best" is defined by cross-platform support, compiler independence, and reasonable performance across a the most common languages in use. ...

Reading from a promiscuous network device

Does anyone know how to read from a promiscuous (or sniffing) device in C? I know that you need to have root access to do it, but I was wondering if anyone knew what functions were necessary to do this (normal sockets wouldn't seem to make sense here)? I want to write a real-time analysis tool for wireless traffic. ...

Test Automation with Embedded Hardware

Has anyone had success automating testing directly on embedded hardware? Specifically, I am thinking of automating a battery of unit tests for hardware layer modules. We need to have greater confidence in our hardware layer code. A lot of our projects use interrupt driven timers, ADCs, serial io, serial SPI devices (flash memory) etc.. ...

What is the difference between vmalloc and kmalloc?

I've googled around and found most people advocating the use of kmalloc, as you're guaranteed to get contiguous physical blocks of memory. However, it also seems as though kmalloc can fail if a contiguous physical block that you want can't be found. What are the advantages of having a contiguous block of memory? Specifically, why would I...

C compiler for Windows?

I know C is not a very popular language but I need it for school. I'm fine working on Linux using gcc as my C compiler but would like a Windows solution. Any ideas? I've looked at Dev-C++ from Bloodshed but looking for more options. ...

What is the best way to only include certain libraries on certain operating systems in c/c++?

When writing an app that one wants to have compile on mac, linux and windows, what is the best way of managing the different libraries that will need to be included on the various operating systems. For example, using the glut opengl toolkit requires different includes on each operating system. ...