c

compiling c++ with gcc/g++ complier

hi im new to c++ and i want to compile my testprogram . i have now 3 files "main.cpp" "parse.cpp" "parse.h" how can i compile it with one command ? ...

minimum double value in C/C++

Is there a standard and/or portable way to represent the smallest negative value (e.g. to use negative infinity) in a C(++) program? DBL_MIN in float.h is the smallest positive number. ...

Resizing a char[x] to char[y] at runtime

OK, I hope I explain this one correctly. I have a struct: typedef struct _MyData { char Data[256]; int Index; } MyData; Now, I run into a problem. Most of the time MyData.Data is OK with 256, but in some cases I need to expand the amount of chars it can hold to different sizes. I can't use a pointer. Is there any way to resize ...

How can I configure Vim to compile C code using Borland's compiler on Windows?

I am new to the text editor Vim. I want to use it for programming C. I am using Windows and the bcc32 compiler from Borland. I cannot seem to get my C code to compile. I think something is wrong with my setup. Can someone give step by step information on how to setup Vim for compiling using BCC? ...

compiling on windows and linux

Hello, I am new to c, and I have some been given some source code that someone else has written that was compiled on windows. After trying to make in compile on linux I have errors because linux doesn't support DWORD, WORD, AND UINT32. I have 6 files for example. A.h, A.c, B.h, B.c, C.h, C.c. These keyword are in all the files. So I...

Code execution path checker?

I recently had the opportunity to shadow a developer for a day. (I'm currently working on my CS degree.) He showed me a tool for generating all possible execution paths through a C program, but I can't remember what it's called, nor have I had any success finding it. I believe it was an open source tool, but I'm not certain. ...

USB Communication API

Is there a decent USB communication API? Preferably cross-platform (Linux if not, I guess) I don't have a specific use in mind, I just want to learn about using the USB ports for future electronics projects. I realize this is very general, I'll try to refine the question as the answers point me in the right direction. Thanks. ...

How to store and call a compiled function in C / C++?

For very low level optimization purposes it would be useful to me if I could store a compiled function inside a variable directly, not a pointer to a function. That is, if I have a function foo, I want to make a char buffer large enough to hold the machine instructions generated for foo, and then be able to in effect call foo by somehow ...

How can I hide the declaration of a struct in C?

In the question Why should we typedef a struct so often in C?, unwind answered that: In this latter case, you cannot return the Point by value, since its declaration is hidden from users of the header file. This is a technique used widely in GTK+, for instance. How is declaration hiding accomplished? Why can't I return the ...

Loading a C/C++ compiler in Linux.

Hi all, Recently i had installed the UBUNTU flavour of the Linux operating system.I had opened a terminal and just wrote a sample C programm to check if it is compiling.When i saved the sample file and compiled with cc a.c ,errors comes that the standard library is not loaded(i.e stdio.h>.When i went to help pages,it says that the...

Bug trying to add two strings with snprintf

I'm trying to add two strings with snprintf but apparently i dont know what i'm doing. Here is the code block: char * filename = NULL; (void)snprintf (filename, sizeof(filename), "%s/%s", PATH, FILE); I also tried: char * filename = NULL; (void)snprintf (filename, sizeof(PATH)+sizeof(FILE)+1, "%s/%s", PATH, FILE); PATH...

Which program creates a C array given any file?

I remember seeing in the past a program that would take any file and generate a C array representing that file as output; it would prevent distribution of a separate file in some cases. Which Unix/Linux program does that? ...

should I be calling lckpwdf() prior to getspent()?

Is lckpwdf() and ulckpwdf() intended to be used only for apps directly accessing the shadow password file? More precisely, my question is: If I call the usual API such as getspnam() or getspent(), should I be calling lckpwdf() first, or is that automatically done by getspnam(), etc...? ...

To understand a C code about endianness

I am studying big and little-endianness. 1. What is the purpose of | \ in the following code? ... #elif defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN) #define htons(A) ((((uint16_t)(A) & 0xff00) >> 8) | \ (((uint16_t)(A) & 0x00ff) << 8)) ... 2. What is the purpose of (A) in the code? ...

C Formatting Question (%d versus %u)

What is difference between %d and %u when printing pointer addresses? For example: int a=5; // check the memory address printf("memory add=%d\n", &a); // prints "memory add=-12" printf("memory add=%u\n", &a); // prints "memory add=65456" Please define. ...

#ifdef #else #endif macro question

Hello, I am new to C, and I am maintaining someones code. I came across this in the header file. I can understand that if the source is compiled on the windows it will enter the if statement else if the code is compiled on a linux it will enter the else statement. Correct me if I am wrong. However, the question is why is # (hash) used ...

Interesting problem using printf & scanf only...

I'm running out of ideas for my "Beginning C" class, and the only topics I've discussed so far are Data types, Variables & the printf & scanf functions. My last quizzes involved simple formulas (area of a circle, volume of a cube..) enclosed inside the printfs.. eg. printf("volume = %d",length * width * height); I'm looking for some...

How to update an older C extension for Python 2.x to Python 3.x

I'm wanting to use an extension for Python that I found here, but I'm using Python 3.1 and when I attempt to compile the C extension included in the package (_wincon), it does not compile due to all the syntax errors. Unfortunately, it was written for 2.x versions of Python and as such includes methods such as PyMember_Get and PyMember_S...

Reasons not use Winsock for HTTP request?

I currently use a simple winsock solution (WSAStartup, socket, connect, send, recv, closesocket) for HTTP-requests to get a 32 byte response of our own server. Is there a performance or security reason to switch to WinHTTP or another library? ...

Is there an alternative sleep function in C to milliseconds?

I have some source code that was compiled on windows. I am converting it to run on red hat linux. The source code has included the windows.h header file and the programmer has used the Sleep() function to wait for a period of milliseconds. This won't work on the linux. However, I can use the sleep(seconds) function, but that uses inte...