"fork() creates a new process and the child process starts to execute from the current state of the parent process". This is the thing I know about fork() in LINUX.
So, accordingly the following code :
int main() {
printf("Hi");
fork();
return 0;
}
needs to print "Hi" only once as per the above.
But on executing the above in l...
I'd like to add some degree of "scriptability" to a application I'm writing. Roughly speaking, I'd like a way to embed a programming language API into my program. I've looked at TinyPy, but I'm worried that - given it's small size - it might be deceptively limiting (i.e. it looks and feels like Python, but is lacking many of the features...
I am trying to pass an array of character strings (C style strings) to a function. However, I don't want to place a maximum size on length of each string coming into the function, nor do I want to allocate the arrays dynamically. Here is the code I wrote first:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void fun(char ...
Hello,
I have functon that convert list in array:
void* list_to_array(SList* list)
{
int i;
int array_size = list_get_length(list);
void* array[array_size];
for (i = 0; i < array_size; i++)
{
array[i] = list_get_n_data(list,i);
}
return *array;
}
But when i try to test it:
int* a = (int*)l...
I'm working with a legacy embedded debugging tool and it's frustrating to work with. I just found out however that it can be automated in many ways, such at setting breakpoints on start up.
Since I use eclipse cdt as my development environment, I was wondering if I could write an eclipse plugin that reads all my breakpoints so I can ge...
It seems that most new programming languages that have appeared in the last 20 years have been written in C. This makes complete sense as C can be seen as a sort of portable assembly language. But what I'm curious about is whether this has constrained the design of the languages in any way. What prompted my question was thinking about ho...
Hey Guys
Is there a way Convert a number from Base B1 to Base B2 without using any intermediate base.
Ex:
214 from base 5 to base 16 without converting it first to decimal and then decimal to hexadecimal.
--
Thanks
Alok Kr.
...
I just saw this code here.
int32_t safe_div_int32_t (int32_t a, int32_t b) {
if ((b == 0) || ((a == INT32_MIN) && (b == -1))) {
report_integer_math_error();
return 0;
} else {
return a / b;
}
}
Just wondering what is wrong with the division (a/b) when a = INT32_MIN and b = -1. Is it undefined? If so why?
...
Hi there,
I have some lines I want to parse from a text file. Some lines start with x and continue with several y:z and others are composed completely of several y:zs, where x,y,z are numbers. I tried following code, but it does not work. The first line also reads in the y in y:z.
...
if (fscanf(stream,"%d ",&x))
if else (fscanf(strea...
I often hear people say that C doesn't perform tail call elimination. Even though it's not guaranteed by the standard, isn't it performed in practice by any decent implementation anyhow? Assuming you're only targeting mature, well implemented compilers and don't care about absolute maximum portability to primitive compilers written for...
Hi guys,
I am writing some program in C. It has a part where it does some probability calculations, where I am using log function. normal library function log()...
The code is something like this
double somevalue = 0.29558101472995091;
temp = log(somevalue)
And guess what? The temp gets value -1856.0000000000000!!!
As the value gi...
// Create test video frame
void CreateFrame(char * buffer, int w, int h, int bytespan)
{
int wxh = w * h;
static float seed = 1.0;
for (int i = 0; i < h; i ++)
{
char* line = buffer + i * bytespan;
for (int j = 0; j < w; j ++)
{
// RGB
line[0] = 255 * sin(((float)i / wxh * seed) * 3.14);
line[1] = 25...
I'm having some problems statically linking ncurses to one of my programs
Here's a really simple sample program:
#include<ncurses.h>
int main(){
initscr();
printw("Hello world\n");
refresh();
getch();
endwin();
return 0;
}
When I compile it with
gcc -static -lncurses hello_curses.c -o curses
I get these...
I have to write code in C to extract a password protected rar file in windows. I don't have any clue about how to do this. can anybody suggest me something or provide a sample piece of code? I will be very thankful.
EDIT:
This is the code I am using to open the rar file.In the system command ranjit is the password. It's giving the erro...
How do I pass the m matrix to foo()? if I am not allowed to change the code or the prototype of foo()?
void foo(float **pm)
{
int i,j;
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++)
printf("%f\n", pm[i][j]);
}
int main ()
{
float m[4][4];
int i,j;
for (i = 0; i < 4; i++)
for (j = 0; j ...
can anyone provide some help with it . i am totally unable to do this one.i tried to do some coding but it didn't work at all. Anyways i have included the code.It is incomplete and wrong anyways.
#include<stdio.h>
#include<math.h>
main()
{
int rows, columns, iter, i,j,k;
printf("enter the number of rows and columns:");
scanf("%d, ...
I have two dll's a.dll and b.dll along with their library files a.lib and b.lib. I am trying to write a third dll that has functions that has to make use of functions in a.dll and b.dll.
Is this possible at all?
The output has to be a dll in itself - that is an absolute requirement.
I have the full C source code.
...
Hi,
This is my follow up to the previous post on memory management issues. The following are the issues I know.
1)data races (atomicity violations and data corruption)
2)ordering problems
3)misusing of locks leading to dead locks
4)heisenbugs
Any other issues with multi threading ? How to solve them ?
...
Is there a built in function to convert ints to Big-endian or little-endian for sending over the network? like htonl and ntohl in c
Also, is there something similar to strings, datetime, etc..
Thanks
...
I'm sort of new to web programming, but I wanted to write a HTML interface for a embedded device (coded in C) that I am developing. I've already implemented a stream server (a la beej's socket server example) and a java client, but I'm interested in implementing a HTML5 Socket interface instead.
I am having some trouble with the handsh...