c

tempnam equivalent in C++

Hi, I need to generate random names which I'll be using to create temporary files in a directory. Currently I am using C standard function tempnam() for this. My code is in C++ and would like to use C++ equivalent for doing the same task. The code needs to work on Solaris as well as on Windows. Is anyone aware of such thing in C++? Any...

Is there an equivalent to Perls' split() function in C?

I'm trying to split real numbers in a C program using the decimal point as the delimter such that such that say, 1234.56 yields (int) whole_num = 1234 (int) fraction = 56 Any ideas how I can go about doing this? Its been a loooong while since I mucked around with C, see? :) ...

using WTO to print from with in Metal C

I’m trying to use the WTO instruction from with in Metal C to print out "Hello World" to my job log. This is based on the example in section 1.2.3.5 of the z/OS V1R10.0 Metal C Programming Guide and Reference It appears when I use WTO I am having either issues with my buffer containing 0 or ASCII to EBCDIC conversion. I’ve pasted the rel...

Sleep function in c in windows. Does a function with better precision exist?

I was wondering if anyone knew of a better sleep function that could be used in windows in c, other than Sleep(), which takes a millisecond input and only guarantees that the input is the minimum amount of time that elapses. I am passing in 1 millisecond, but actually getting a 15-16 millisecond delay. Is there any way to accurately set ...

Using a .lib file from C

I am new to C/C++. I have a static library (.lib) file created using VC++. (I also have .h file for it). And I need to use this in a C program. Can you please help me doing this? Thank you, Prashanth. ...

constants and pointers in C

I wanted to change value of a constant by using pointers. Consider the following code int main() { const int const_val = 10; int *ptr_to_const = &const_val; printf("Value of constant is %d",const_val); *ptr_to_const = 20; printf("Value of constant is %d",const_val); return 0; } As expected the value of consta...

Passing a pointer to pointer to character into a function

C99 I am using a pointer to pointer and passing it into a function to display the names. However, when I go through the debugger. The pointer to pointer in the parameter points to nothing. However, I am using it to display all the names in main. If I was passing an integer the integer value would still be there. Why not a pointer to p...

How to use IDispatch in plain C to call a COM object

I need to compile some code of mine using the gcc compiler included in the R tools (R the statistical program for windows), the problem is that I need to use IDispatch in my code to create an access the methods of a COM object, and the gcc compiler doesn't support much of the code that I'm using to do so, which is basically C++ code. So...

problems with memset in Metal C

I’m trying to initialize the Metal C environment with the following code, but get the following errors on the memset line. ERROR CCN3275 IMIJWS0.METAL.SAMPLIB(MEM):6 Unexpected text ')' encountered. ERROR CCN3045 IMIJWS0.METAL.SAMPLIB(MEM):6 Undeclared identifier ___MEMSET. ERROR CCN3277 IMIJWS0.METAL.SAMPLIB(MEM):6 Syntax ...

How should a C++ programmer design software in C?

As a C++ programmer, we have to deal with concepts and the relation of related concepts before implementing them to classes. However,how to design a software in procedure languages like C ? How can I deal with concepts without the help of class in C++. Related: What is the best way to plan and organize development of an application ...

Are there any benefits to NOT using function prototypes in C?

I'm working with some C code that does not contain function prototypes for a certain class of functions. Are there any advantages to not using function prototypes? The functions never call each other and have no parameters. The code changes a lot, so maybe it's just one less line to edit? ...

What if any, programming fundamentals are better learned in C as opposed to C++?

As a person who wanted to increase his fundamental programming skills, I chose to learn C++ instead of C. Which leads me to ask: Is there any fundamental skills that I leave in C that might not be obtained by learning C++? Related question: Should I learn C before learning C++? ...

Follow original author's coding style? Even if it is horrible / lazy / makes your eyes bleed?

When contributing to a very old, and apparently no longer maintained, open-source or public domain project, is it suggested practice to follow the original author's coding style even if it is terrible? More importantly, are there any reasons why one would want to follow the original author's coding style rather than clean it up signifi...

asynchronous serial port communication in windows in c

I am getting an error when I try to run a c file which does some basic writes to a serial port. I am trying to run it asynchronously because the writes sometimes take a long time to transfer. My original version had it running synchronously with WriteFile() commands which worked fine. I am new to using OVERLAPPED and would appreciate and...

Does this multiple pipes code in C makes sense?

I've created a question about this a few days. My solution is something in the lines of what was suggested in the accepted answer. However, a friend of mine came up with the following solution: Please note that the code has been updated a few times (check the edit revisions) to reflect the suggestions in the answers below. If you intend...

What do these C operators mean?

I'm reading the book "Programming Challenges: The Programming Contest Training Manual" and are implementing a problem where I do not understand the use of operators c>>1 and the comparison if (n&1), someone could help me to know they mean? this is the example code #include <stdio.h> #define MAX_N 300 #define MAX_D 150 long cache[MAX_...

The specified module could not be found - 64 bit dll

Hi Everyone, I had the 32 bit dll which is written using Native C, when I tried compiling with VC++(VS2008) for converting the dll to x64 by changing the platform it compiled. But when I tried to access the dll from my C# application which is also 'x64' platform it fails to load the dll. I used Dllimport for linking the dll with my appl...

Could anyone explain these undefined behaviors (i = i++ + ++i , i = i++, etc...)

int main(int argc, char ** argv) { int i = 0; i = i++ + ++i; printf("%d\n", i); // 3 i = 1; i = (i++); printf("%d\n", i); // 2 Should be 1, no ? volatile int u = 0; u = u++ + ++u; printf("%d\n", u); // 1 u = 1; u = (u++); printf("%d\n", u); // 2 Should also be one, no ? register int v = 0; v...

stack dump using alloc

Hello, I seem to be getting a stack dump in my function where I am allocating memory. I am passing an array of pointers '**output' to my function. And then I allocate enough memory to assign into that memory a string. However, I am getting a stack dump. Many thanks for any suggestions, void display_names(char **names_to_display, char...

What are the different calling conventions in C/C++ and what do each mean?

There are different calling conventions available in C/C++ stdcall, extern, pascal etc. How many such calling conventions are available and what do each mean? Are there any links that describe these? ...