c

c language problem

hi! everybody i have a c problem can any one help me . i wrote a code of process creation in c language , it uses pid & fork() call. the fork call is use for making child process now can any body tell me how to make parent process? i know that creating a child in process make the process parent automatically but i want to make a parent ...

Linux: Hard disk direct access (without any FS) from C program

Hello all, this is my first post here. I want to access the whole hard disk directly from a C program. There's no FS on it and never's gonna be one. I just want to open /dev/sda (for example) and do I/O at the block/sector level of the disk. I'm planning to write some programs for learning C programming in the Linux environment (...

Function pointers in FSM

HI.. I want an example of how to implement FSM using function pointers in C. ...

Testing how semaphores work.

I am trying to test the action of semaphores by calling them in my program with manual switches. I have the functions ready to go, but am failing to codinate them during the calling. I using UNIX system. Please NOTE: the function defitions are fine, put them here for quick refence.The problem is with the caline below these function. I wi...

Simple tar implementation?

Hallo, I'm looking for a really simple and easily hackable tar library for C or C++. Ideally it should have a permissive license (BSD/LGPL) and not have a ton of Unix/Windows OS dependencies, as I plan to use it from an embedded RTOS... Any ideas? ...

POSIX shared memory + directories

The OS I'm working on (IBM CNK, which is not Linux, but somewhat POSIX-compliant) doesn't allow me to simply create a new file or directory in /dev/shm using fopen() or mkdir(), respectively. It looks like I have to use shm_open() to get a file descriptor and then fdopen() to use the shared region for file I/O. Do I need to set the siz...

Explanation of how to interpret hex values in a function

My program is working perfectly, but this was achieved through trial and error; I am trying to get a grip of how things really work from first principles. I will be grateful for any explanation. What is this function communicating with the hexadecimal values? for (i=0; i<5;i++) { cd=(int)(((numpairs[i])&0xf0)>>4); if((numpair...

How to input 8 byte hexadecimal number into char array?

Hi I want to generate sequence of hexadecimal numbers starting with 07060504003020100. Next number would be 0f0e0d0c0b0a0908 etc in that order. When i use unsigned long long int and output the data first 4 bits ie 0 is truncated. and it prints 706050403020100. So i was thinking of puting the number into a char array/buffer and then pr...

Making C code plot a graph automatically.

I have written a program which writes a list of data to a '.dat' file with the intention of then plotting it separately using gnuplot. Is there a way of making my code plot it automatically? My output is of the form: x-coord analytic approximation x-coord analytic approximation x-coord analytic approximation x-coord ...

C: declare a constant pointer to an array of constant characters

Hi, I am trying to understand array declarations, constness, and their resulting variable types. The following is allowed (by my compiler): char s01[] = "abc" ; // typeof(s01) = char* const char s02[] = "abc" ; // typeof(s02) = const char* (== char const*) char const s03[] = "abc" ; // typeof(s03) = char const* (== const char...

blanking a char variable in c

I have declared a char variable ope in function main. i took the input through getchar function and stored in ope. Now i want to blank the variable so i will be able to store some other in ope. Can anybody show me how to do it?? I just want to continuously store the input in ope variable. If it's possible through some other way, kindly g...

Is there really no mremap in Darwin?

I'm trying to find out how to remap memory-mapped files on a Mac (when I want to expand the available space). I see our friends in the Linux world have mremap but I can find no such function in the headers on my Mac. /Developer/SDKs/MacOSX10.6.sdk/usr/include/sys/mman.h has the following: mmap mprotect msync munlock munmap but no mre...

C Library to read configuration files with syntax based on curly brackets.

For my C projects I'd like to use curly brackets based configuration files like: account { name = "[email protected]"; password = "test"; autoconnect = true; } etc. or some variations. I'm trying to find some nice C libraries to suit my needs. Can you please advise? ...

NPTL caps maximum threads at 65528?

The following code is supposed to make 100,000 threads: /* compile with: gcc -lpthread -o thread-limit thread-limit.c */ /* originally from: http://www.volano.com/linuxnotes.html */ #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <pthread.h> #include <string.h> #define MAX_THREADS 100000 int i; void run(void) { ...

How to break 32 bit value and assign it to three different data types.??

I have a #define PROT_EN_DAT 0x140 //(320 in decimal) Its loaded into 64 bit value register(ex setup_data[39:8]=PROT_EN_DATA) Now i want to put this value(0x140)into uint8_t bRequest uint16_t wValue uint16_t wIndex How can load the value so that i don't have to manually do it for other values again. I think we can do...

Socket programming at low level

Hi, I am unable to understand or grasp rather; what it means to program at a lower layer in socket programming. I am used to working with tcp/udp/file system sockets. These are all wrapped around their own protocol specifications ... which as i understand would make it working at the application layer in the stack. In the project i am ...

Is there any code editor that works on touch screen mobile phones?

Is there any code editor (like eclipse or visual studio) that works on mobile phones (such as nokia 5800)? So what I want is to edit my C/C++/C# code on my phone. (I have Nokia so it is my primary intrest, but I am also interested in other phones such as Android based ones.) I do not need ability to compile, but I'd love codehinting an...

how can I solve non linear simultaneous equations?

i am having 12 equations and 12 unkonwns... i want to solve these equations. please help me with software or package or source code. ...

parsing space separated text in C

I'm writing a program for a school project that is supposed to emulate the Unix shell, in a very basic form. It's basically parsing input, then doing a fork/exec. I need to be able to read arguments in the program (not as arguments passed to the program from the command line) individually. For example, I will prompt: Please enter a com...

How to convert the time to a c string in c?

Hi, I wanna to write something to a .txt file in .c file, but required to name that file with the current timestamp as the postfix, just like filename_2010_08_19_20_30. So I have to define the filename char array first and process the filename by myself?Assign the character one by one? Is there any easy way to do that? ...