c

How to make a .com file using C/C++?

How can we make a .com file using C/C++? Is it possible? Edit: I was able to successfully make a com file using darin's suggestions. But somehow the exe file of the following program cannot be converted to com file. I get the "File cannot be converted" message by exe2bin. I'm using Borland Turbo C++ 3.0. Any suggestions? #include <dos....

Should we still be optimizing "in the small"?

I was changing my for loop to increment using ++i instead of i++ and got to thinking, is this really necessary anymore? Surely today's compilers do this optimization on their own. In this article, http://leto.net/docs/C-optimization.php, from 1997 Michael Lee goes into other optimizations such as inlining, loop unrolling, loop jammin...

Designated Initializers

can any body plz explain the following line about the designated intializers: The initializer list can omit elements that are declared anywhere in the aggregate, rather than only at the end. ...

Eclipse has two C/C++ indexers (fast & full): what's the difference?

Eclipse CDT provides two indexers for C/C++ code (Preferences > C/C++ > Indexer). Does anybody know what the exact difference is between these two? The help file isn't exactly enlightening: "CDT supports the contribution of additional indexers, with 2 indexers being provided with the default CDT release: Fast C/C++ In...

MS compiler optimization that replaces variables in a function?

I'm not sure how to explain the behavior I'm seeing, but here goes. I have a function foo that takes three parameters, a pointer, an int, and another pointer. When I break-point inside foo, I can clearly see that all the variables are the values they should be. However, when I step down beyond the local variable declarations, one of t...

Pointer memory error

The problem I can't get the data from the Flash memory when using the function that return the address of the pattern desired in the Flash (simplified in the example below with only 1 constant : PATTERN_P). Some code before explication The type patternp is defined as typedef prog_uchar patternp[NUM_ROWS]; The global PATTERN_P vari...

What sort of businesses still hire C programmers?

I'm starting a job search, ideally ending up at a C shop. So far, I'm coming up empty in my local ads, and am starting to think I need to broaden my search, targeting specific types of businesses. So, what type of places typically use this language? ...

Significance of Hex numbers specified in RFC 3174 (SHA-1)

I'm trying to learn about SHA-1, I was looking at the C implementation that was included in the specification (RFC 31741) and this part confuses me: context->Intermediate_Hash[0] = 0x67452301; context->Intermediate_Hash[1] = 0xEFCDAB89; context->Intermediate_Hash[2] = 0x98BADCFE; context->Intermediate_Hash[3] = 0x10325476; cont...

What limits the number of nested loops in c?

Edit: For those of you looking for an answer to the question as stated the standard limits the number of nested loops at compile time. At runtime this is a different issue as the only limit would be the size of the program segment. Solved: I was looking too early on in the build process. The c file gets further preprocessing applied t...

Determining Which Compiler Built a Win32 PE

How can one determine which C or C++ compiler was used to build a particular Windows executable or DLL? Some compilers leave behind version strings in the final executable, but this seems to be rarer on Windows than on Linux. Specifically, I'm interested in distinguishing between Visual C++ and the various MinGW compilers (usually fairl...

Inputing into other programs [C/C++]

So I have a C program that runs on the Windows Platform that periodically sends emails of log files , it is supposed to run in the background with no interference. I don't want to make the email address a constant. What are some ways to input an email address into this program? I was thinking of a simple script that just takes paramete...

Is it common to indent code at scope only braces?

For generated code I have an option to either indent or or not indent at braces which are only used to house variables at scope. Currently it does not indent at this level and I am wondering if I am going to imply a nested structure by indenting it? What is the common practice? /* loop through the total number of letter a rules */ fo...

Phar Lap Assembler: I Need information/documentation and binaries if possible.

I've inherited a rather old big and complex codebase for a program originally targeted at MSDOS. It turns out that some sections of this program are written in an obscure dialect of x86 assembler called "Phar Lap assembler", after the company and product that produced the assembler program. I've done a fairly deep google search and I'm u...

Programming a Steganography application in C/C++

I have been reading up on on steno for a while. I have seen tools that help aid in embedding messages in .mp3's and png's etc. I am familiar that they do this by replacing the least important bit. In images, these LIB are colors that the human eye can't see; thus not needed. In audio files frequencies not audible to the human ear; also n...

binary format to pass tabular data

I'm maintaining a legacy embedded device which interacts with the real world. Generally speaking, this device collects data from sensors, processes the data using its internal algorithm, and displays warning when data reaches a certain "bad" state. For debugging purposes, we wish this device will send us on a regular basis many of the d...

propagation of "-g" in shared libraries with gcc

I have the a program abc. abc uses the library def and def in turn includes a library ghi. Now, libghi.so is compiled and linked using gcc -g. libdef.so is also compiled and linked using gcc -g. However, abc isn't linked with -g. The question is, if I debug abc with gdb should I be able to see the symbols in def and ghi? The projec...

How can you do C++ when your embedded compiler doesn't have operator new or STL support?

I am working on a group senior project for my university and I have run into a major hurdle in trying to get my code to work. The compiler that we have for our 8 bit Atmel microcontroller does not support the new or delete operators, and it does not support the C++ STL. I could program it in C, but I have to implement an A* algorithm w...

Why does tm_sec range from 0-60 instead of 0-59 in time.h?

My time.h has the following definition of tm: struct tm { int tm_sec; /* seconds after the minute [0-60] */ int tm_min; /* minutes after the hour [0-59] */ int tm_hour; /* hours since midnight [0-23] */ ... } I just noticed that they document tm_sec as ranging between 0-60 inclusive. I've always assumed it ranged fro...

Simple random number generator C

Hi, Looking to make a really simple random number generator method in C. The numbers should be between 0 and 24 and can be for example 14.5f. Any help would be great, thanks! ...

Why does this allow promotion from (char *) to (const char *)?

Given that scanf has (const char *) in the documentation from Microsoft and the answer to this question what the heck is going when I do the same for (char **) promotion to (const char **)? Basically why does this compile? #include <stdio.h> int main(int argc, char **argv) { char szArray[50]; int i = 0; strcpy(szArray,...