#include <stdio.h>
#include <stdlib.h>
typedef int element;
struct cell {
element e;
struct cell *p;
};
typedef struct cell* CELL;
int main() {
CELL* p;
p = (CELL*) malloc (sizeof(struct cell));
p->e = 8; /* This ain't working */
*p.e = 8; /* This doesn't help anything either */
return 0;
}
I...
#define MAX 100
int *p;
int *tos;
int *bos;
void push(int i);
int pop(void);
int main ()
{
int a,b;
char s[80];
p = (int *) malloc(MAX*sizeof(int)); /* get stack memory */
if (!p)
{
printf("Allocation Failure\n");
exit(1);
}
tos = p;
bos = p + MAX-1;
printf("\nRPN Calculator\n");
printf("Enter 'i' for integ...
Possible Duplicates:
[C] Header per source file.
In C++ why have header files and cpp files?
C++ - What should go into an .h file?
Is the only reason header files exist in C is so a developer can quickly see what functions are available, and what arguments they can take? Or is it something to do with the compiler?
Why has...
Hi,
I am writing a C++ program which needs to create a temporary file for its internal usage. I would like to allow concurrent executions of the program by running multiple proccesses, so the temporary file name needs to be randomized, that way each spawned process will generate a unique temporary file name for its own use.
I am using r...
Hi,
I wonder if there is something like eps to represent the value of machine precision in C++? Can I use it as the smallest positive number that a double can represent? Is it possible to use 1.0/eps as the max positive number that a double can represent? Where can I find eps in both C++ and C standard libraries?
Thanks and regards!
...
How do I set the modification time of a file programmatically?
OS: Windows
Programming Language: C
...
I have the following struct:
struct cell {
int nmbr;
struct cell *p;
};
I have created a chain of linked structs from this type. Every struct is connected to its predecessor through *p. If I decide to print all nmbrs with a recursive algorithm as shown below, how do I define the stop condition?
void write(struct cell* l) {
...
Does anyone know of a good Java to C cross compiler?
Do they work well?
...
Hello,
I have a lot of data stored in bin format as a sequence of structs. I want to be able to read randomly any of the structs and modify it in C. I am trying with the following code but it doesn't work. Can someone fix it for me please?
Also, would it be possible to delete an intermediate struct from the file in between?
The code i...
I would like to be able to enter a character from the keyboard and display the binary code for said key in the format 00000001 for example.
Furthermore i would also like to read the bits in a way that allows me to output if they are true or false.
e.g.
01010101 = false,true,false,true,false,true,false,true
I would post an idea of ho...
I can't seem to compile this basic program using glib.h...
#include glib.h
#include stdio.h
int main ()
{
return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); ;
return 0;
}
glib.h is located in /usr/local/include/glib-2.0
So I compiled with
$ gcc -v -c -mcpu=v9 -I/usr/local/include/glib-2.0 testme2.c ...
Hi guys, sorry in the past I have not been able to formulate my question coherently. This will be my last try. =|
Basically, I want to do something like this website is doing: http://www.ninjavideo.net/video/56388. They are rendering an iframe that points to a port on localhost. You will see nothing in the iframe if you dont have their ...
Hi,
(1) I have met several cases where epsilon is added to a non-negative variable to guarantee nonzero value. So I wonder why not add the minimum value that the data type can represent instead of epsilon? What are the difference problems that these two can solve?
(2) Also I notice that the inverse of the maximum value of a double prec...
The aim of the program is to fork a new child process and execute a process which also has command line arguments..
If i enter "/bin/ls --help". I get the error...
shadyabhi@shadyabhi-desktop:~/lab/200801076_lab3$ ./a.out
Enter the name of the executable(with full path)/bin/ls --help
Starting the executable as a new child process...
B...
I recently ran into a very sneaky bug, in which I forget to dereference a pointer to a string (char array) and thus sometimes overwrote one byte on the stack.
Bad:
char ** str;
(*str) = malloc(10);
...
str[2] = 'a'; //overwrites 3 bytes from the location in which str is stored
Corrected:
char ** str;
(*str) = malloc(10);
...
(*str...
I have a C program which gets spawned from a Java program. The C program is mine, while the Java program is third party. The Java program somehow sets things up so that it communicates with my program via stdin/stdout.
The system has been working fine under 32-bit Windows XP for years. I have just purchased a new machine with 64-bit Win...
I'm trying to write an app that can login to SSH with a password, by using pseudo terminals. But if I write() to the master device then the data somehow does not appear in the slave device. Here's a simple test case:
#include <sys/wait.h>
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
#ifdef __linux__
#include <pty.h>...
Hello,
It appears to me that one way of storing data in a B-tree as a file can be done efficiently with C using binary file with a sequence (array) of structs, with each struct representing a node. One can thus connect the individual nodes with approach that will be similar to creating linked lists using arrays. But then the problem that...
My program basically runs a executable file with command line arguments.
A child process is forked and the output of the child process is taken in the file "filename".
The problem is that the file is made and the data is written but it can only be opened by the root user.. How can make it readable to the user who invoked the program?
T...
I'm developing program for Cortex-M3. It doesn't have floating point coprocessor. Standard C library can emulate floating point operations, but I don't use it due to its size.
Is there any good and free c library, which can emulate floating point arithmetics, targeted on ARM processors?
Currently, when I use floating point operators I h...