A pointer in C is the address of something. It is a rare case indeed when we care what the specific address itself is, but pointers are a quite common way to get at the contents of something. The unary operator ‘&’ is used to produce the address of an object, if it has one. Thus
int a, b;
b = &a;
puts the address of a into b We can’t do much with it except print it or pass it to some other routine, because we haven’t given b the right kind of declaration. But if we declare that b is indeed a pointer to an integer, we’re in good shape:
int a, *b, c;
b = &a;
c = *b;
b contains ...
Tuesday, July 12, 2011
CREATE NEGATIVE FROM PNG IMAGE
HI,here we will discuss about how we can create a negative image from png image by using C program.The source code of C Program is given below.Just try it.
SOURCE CODE
/*CREATE NEGATIVE FROM PNG IMAGE*/
#include <stdio.h>
#include <error.h>
#include <gd.h>
int main(int argc, char *argv[]) {
FILE *fp = {0};
gdImagePtr img;
char *iname = NULL;
char *oname = NULL;
int color, x, y, w, h;
int red, green, blue;
color = x = y = w = h = 0;
red = green = blue = 0;
if(argc != 3)
error(1, 0, "Usage: gdnegat input.png output.png");
else ...
Saturday, July 9, 2011
BEEPS THE SPEAKER-C SOURCE CODE
/*Beeps the speaker using C program*/
#include <dos.h>
#include <stdio.h>
#include <stdlib.h>
int menu(void);
main()
{
while(1)
{
/*get selection and execute the relevant statement*/
switch(menu())
{
case 1:
{
puts("sound the speaker 1\n");
sound(2000);
sleep(2);
nosound();
break;
}
case 2:
{
puts("sound that speaker 2\n");
sound(4000);
sleep(2);
nosound();
break;
}
case 3:
{
puts("You are quitting\n");
exit(0);
break;
}
default:
{
puts("Invalid menu choice\n");
break;
}
}
}
return 0;
}
/*menu function*/
int menu(void)
{
int reply;
/*display menu options*/
puts("Enter ...
EMPTY RECYCLE BIN USING C PROGRAM
/*Source code of C program--EMPTY RECYCLE BIN*/
#include<stdio.h>
#include<windows.h>
#include<shlobj.h>
#define WIN32_LEAN_AND_MEAN
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
if(MessageBox(NULL, "Press ok to empty the Recycle Bin.", "recycler", MB_YESNO | MB_ICONINFORMATION) != IDYES)
return FALSE;
SHEmptyRecycleBin(NULL, "", 0);
return FALSE ;
}
...
Saturday, July 2, 2011
Small C Program-Convert IP address to it's base10 form
/*SOURCE CODE OF SIMPLE PROGRAM--CONVERT IP ADRESS TO IT'S BASE10 FORM*/
#include<stdio.h>
#include<getopt.h>
#include<sys/types.h>
#include<locale.h>
#include<regex.h>
#define PACKAGE "ip2b10"
#define VERSION "0.0.2"
#define URL "WWW"
#define IPEXPR "([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})"
void print_help(int exval);
void print_version(int exval);
int main(int argc, char *argv[]) {
regex_t re;
int opt = 0;
int print_flag = 0;
long unsigned int result = 0;
int var1 = 0, var2 = 0;
int ...
Friday, July 1, 2011
Switch Case Statement in C
The switch case statement allows you to select from multiple choice based on a set of fixed value for a give expression.The value of the variable given into switch is compared to the value following each of the cases.And when one value matches the value of the variable,the computer continues executing the program from that point.
Syntax of the 'switch case' statement is:
switch(expression)
{
case value1: /*execute code1*/
break;
case value2: /*execute code2*/
break;
.....
default: /*execute default action*/
break;
}
Example:
/*Program ...
Subscribe to:
Posts (Atom)