#define pi 3.142
void main()
{
float circum,r;
printf("entr radius");
scanf("%f",&f);
area=2*pi*r;
printf("circum of the circle is =%f",f);
}
We have to write another C program which takes a file as input and replaces the string "pi" with the defined value
Where ever define variable is there i should replace with the value d...
I am using the standard FindFirst and FindNext to retrieve all files in a directory
but I need the results to come back sorted ( in the same order that clicking on the name column in explorer would sort them basically )
How can I achive this
This has to be done via Win32
Thanks
...
Hi, I'm trying to complete a project for school involving the use of semaphores. I have included the proper header files ( plus one for pthreads). I have pointed the compiler to the proper libraries as well. This is written in C. Yes, this is an assignment, but please be aware I am not looking for help with implementation, rather I can't...
hey,
lets say we have a binary protocol, with fields network ordered (big endian).
struct msg1
{
int32 a;
int16 b;
uint32 c
}
if instead of copying the network buffer to my msg1 and then use the "networkToHost" functions to read msg1
I rearrange / reverse msg1 to
struct msg1
{
uint32 c
int16 b;
int32 a;
}
...
How can I capture another process's output using pure C? Can you provide sample code?
EDIT: let's assume Linux. I would be interested in "pretty portable" code. All I want to do is to execute a command, capture it's output and process it in some way.
...
Hello all,
I wish to create a background process and I have been told these are usually written in C or something of that sort. I have recently found out PHP can be used to create a daemon and I was hoping to get some advice if I should make use of PHP in this way.
Here are my requirements for a daemon.
Continuously check if a row ha...
I am porting some c++ code to c. What is a viable equivalent of std::map in c?
I know there is no equivalent in c.
This is what I am thinking of using:
In c++:
std::map< uint, sTexture > m_Textures;
In c:
typedef struct
{
uint* intKey;
sTexture* textureValue;
} sTMTextureMap;
Is that viable or am I simplifying map too much? ...
Can anyone share their experience in adopting the MISRA C specification in their software development process?
...
I'm a programmer with 2 years experience, I worked in 4 places and I really think of myself as a confident, and fluent developer.
Most of my colleagues have CS degrees, and I don't really feel any difference! However, to keep up my mind on the same stream with these guys, I studied C (read beginning C from novice to professional), Data...
For my assembly language class, we're writing DOS programs using DPMI. Unfortunately, I don't have access to a 32-bit windows machine all the time. I do have a Debian virtual machine installed on just about every computer I do use.
I've got both DOSBox and DOSEMU installed. Is there any way that I can assemble and compile the program...
I'm currently converting a small C project (galarm) from autotools to CMake.
In the old configure.in I checked every header and library function for existence using the following lines:
# Checks for header files
AC_HEADER_STDC
AC_CHECK_HEADERS([stdlib.h time.h math.h sys/stat.h errno.h unistd.h fcntl.h signal.h])
# Checks for library ...
This page on the MSDN seems to list a bunch of file operations that behave more or less exactly like condensed versions of the three functions used in this example. What's the purpose of these non-standard run-time functions that do things functions are written for in the Win32 API?
Are they just there for DOS compatibility? If so, then...
Is there a defined behavior for handling a stack overflow?
Apart from terminating the process, it doesn't seem like there's a whole lot that can be done. I'm just wondering if anyone might know what the C standard has to say about it.
...
I am a C# programmer who started using ubuntu about 2 years ago. I'm wanting to learn GUI programming in either C or C++. I don't really like mono, it tends to crash on my system. I have a basic understanding of C++. I have never worked in C, but it looks cool. Which toolkit should I learn/use? Give Pro/Cons of each. Thanks!
...
I basically want to the C of equivalent of this (well, just the part with the array, I don't need the class and string parsing and all that):
public class Example
{
static int[] foo;
public static void main(String[] args)
{
int size = Integer.parseInt(args[0]);
foo = new int[size]; // This part
}
}
Pardon my ...
Hi folks...
Is it possible to store a fraction like 3/6 in a variable of some sort?
When I try this it only stores the numbers before the /. I know that I can use 2 variables and divide them, but the input is from a single text field. Is this at all possible?
I want to do this because I need to calculate the fractions to decimal odds.
...
So I have a couple of functions that work with a string type I have created. One of them creates a dynamically allocated sting. The other one takes said string, and extends it. And the last one frees the string. Note: The function names are changed, but all are custom-defined by me.
string new = make("Hello, ");
adds(new, "everyone");
f...
In a C program, when you write a floating point literal like 3.14159 is there standard interpretation or is it compiler or architecture dependent? Java is exceedingly clear about how floating point strings are interpreted, but when I read K&R or other C documentation the issue seems swept under the rug.
...
I need to build a custom simple non-authoritative caching DNS server in C/C++. Any guidance? Links? Samples?
Thanks!
...
I am trying to write a 2d game engine in C (no c++). What are some good libraries that have generic data types I may need - for example queues, trees, maps, lists, and so on?
...