c

apply checksum in c to a char

How do you apply checkksum to a char in c? ...

How to format input to only accept integer values

input value 123 -- this value is integer, and valid input value 1b23a -- this value is invalid How do I detect which values are valid and not? Here is my code: #include <stdio.h> #include <conio.h> void main() { char str1[5],str2[5]; int num,num1,i; num=0; clrscr(); printf("Enter the Number "); scanf("%s",str1...

In a C function declaration, what does "..." as the last parameter do?

Often I see a function declared like this: void Feeder(char *buff, ...) what does "..." mean? ...

In a process using lots of memory, how can I spawn a shell without a memory-hungry fork()?

On an embedded platform (with no swap partition), I have an application whose main process occupies most of the available physical memory. The problem is that I want to launch an external shell script from my application, but using fork() requires that there be enough memory for 2x my original process before the child process (which wil...

check whether fgets would block

Hi, I was just wondering whether in C is it possible to peek in the input buffer or perform similar trickery to know whether a call to fgets would block at a later time. Java allows to do something like that by calling BufferedReader.ready(), this way I can implement console input something like this: while (on && in.ready()) { line ...

Can you explain the Output ?

What should be the output of the following code and why? I am little bit confused. int a =10; printf("%d %d %d",a,a=a+10,a); ...

Finding the size of a pointer

printf("pointer: %d\n", sizeof(*void)); This line results in a syntax error because of the *. What should I do to get it to work? ...

how to remove extension from file name?

I want to throw the last three character from file name and get the rest? I have this code: char* remove(char* mystr) { char tmp[] = {0}; unsigned int x; for (x = 0; x < (strlen(mystr) - 3); x++) tmp[x] = mystr[x]; return tmp; } ...

c - dereferencing issue

Hi, I have simplified an issue that I've been having trying to isolate the problem, but it is not helping. I have a 2 dimensional char array to represent memory. I want to pass a reference to that simulation of memory to a function. In the function to test the contents of the memory I just want to iterate through the memory and print o...

How to find working directory which works between different computers. - C

Hello, I am running two processes,Process A is opened by Process B using the following example: createProcessHandle = CreateProcess( TEXT("C:\\Users\Jamie\\Documents\\Application\\Debug\\ProcessA.exe"), TEXT(""), NULL, NULL, FALSE, 0...

Release build in MVS 2010 professional v/s express for C

Hi, recently I discovered that "executing" a C program as a release build instead of a debug build optimizes the code and makes it run much faster. This is accessed through project properties > configuration manager menu. I would like to know if this feature is the same in the professional version and in the express edition of MVS 2010 i...

Another C question

Hi all, I have a piece of code shown below #include <stdio.h> #include <stdlib.h> void Advance_String(char [2],int ); int Atoi_val; int Count_22; int Is_Milestone(char [2],int P2); char String[2] = "0"; main() { while(1) { if(Is_Milestone(String...

Image scaling in C

Hi, I am designing a jpeg to bmp decoder which scales the image. I have been supplied with the source code for the decoder so my actual work is to design a scaler . I do not know where to begin. I have scouted the internet for the various scaling algorithms but am not sure where to introduce the scaling. So should I do the the scaling a...

How do I make the gtk code work?

vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), vbox); ... frame = gtk_fixed_new(); gtk_container_add(GTK_CONTAINER(window), frame); ... The above code will generate the warning below: Gtk-WARNING **: Attempting to add a widget with type GtkFixed to a GtkWindow, but as a GtkBin subclass a GtkWindow can...

Implementing callback functions in C

Hi, I am a newbie to C.I am trying to implement callback function using function pointers. I am getting an error :test_callback.c:10: error: expected identifier or ‘(’ before ‘void’ when I try to compile the following program: #include<stdio.h> void (*callback) (void); void callback_proc () { printf ("Inside callback funtion\n...

Is it possible to avoid global variables in a strictly procedural program?

Being a developer born and raised on OO, I was curious to hear how it's possible to avoid global state in a procedural program. ...

learning sample of likely() and unlikely() compiler hints

Hello How can I demonstrate for students the usability of likely and unlikely compiler hints (__builtin_expect)? Can you write an sample code, which will be several times faster with these hints comparing the code without hints. ...

How can I disable editting for GtkTextView in c?

I tried this one and it generates a textview window: http://zetcode.com/tutorials/gtktutorial/gtktextview/ But I don't want it to be editable. BTW,how can I show the scroll bar when the text overflows? ...

What does GTK_WINDOW(window)->allow_shrink = TRUE mean in c?

I'm just getting started with gtk,anyone knows what this means? GTK_WINDOW(window)->allow_shrink = TRUE; ...

Locking semaphores in C problem sys/sem

Hi, EDIT: This peace of code is pretty fine (so take it as example of semaphores ;). Bug in my program was in another place - found by my friend. I have problem with my functions. Sometimes two processes enter into critical section. I can't find problem in this after I spent 10 hours by debugging. On what I should aim? Is there any pos...