Sunday, 10 October 2010

Bat Detector Circuit This Bat Detector Circuit is authored by Chris Eve. Basic tests with a variety of salvaged electret microphones all showed good

Bat Detector Circuit

This Bat Detector Circuit is authored by Chris Eve. Basic tests with a variety of salvaged electret microphones all showed good response to 50kHz and beyond, the smaller the unit the better the response. My tests indicate that a small electret microphone has at least some response to 100kHz and that this response is reasonably "flat" to at least 50kHz.



The microphone I use is approximately 6mm in diameter and can be mounted within the body of a 3.5mm jack plug. Having the microphone socketed rather than fixed within the detector case is optional, but gives further opportunity to experiment with uni-directional or "Pressure Zone" modules (see below), or other microphones mounted remotely from the electronics.

This bat detector circuit to have better sensitivity, both in distance to a visible bat and in audio frequency, than some other published circuits using a 40kHz transducer with 4000x gain amplification, though the 40kHz transducer I used for the comparison may have a bearing on these results.

The high-pass filter is included purely to help eliminate the circuit being triggered by ambient noise. The filter is a 4-pole Chebychev with a very steep roll-off below 15kHz. There is virtually zero response at 10kHz and below. This type of circuit relies on the wanted signal being loud enough to trigger the CMOS counter, so the less unwanted signal that reaches the circuit the better. Whilst any of the basic circuits based around a 40kHz transducer will perform adequately for the detection of bats calling within that frequency range, which includes many of the more common species, this circuit will give much better indication of the presence of less-common bats that call at lower frequencies, around 20kHz, as well, hopefully, those at somewhat higher frequencies.

When used at dusk, when individual bats are still visible, pointing a unidirectional microphone at a solitary bat indicates a usable range of at least 100ft (30m). Bats actually call very loudly indeed ... it's probably a good job we cannot hear them, else they would keep us awake!


This circuit was built in a metal box, because that was what I had to hand, using point-to-point wiring on a ground-plane. Perforated strip-board should be perfectly adequate and probably a lot easier to fault-find should you make a mistake. I do not have nor intend to produce a pcb layout, so please do not ask for one, though if you should feel the need to produce one and have the inclination to share it I would be only too willing to include it (or a link to it) on this page. The circuit may be more susceptable to interference from electronic sources if built in a plastic container. Current consumption is around 15mA with no audio output, so a PP3 battery should last for several evenings unless you have got a lot of bats in your area. For regular or extended use, rechargeable batteries or an external power source would make sense. Note that the LM386 has an absolute maximum voltage of 15v (12v recommended), but the rest of the circuit is OK to 15v. Also be aware, if tempted to use a regulated supply incorporating a 78xx series regulator, that these do generate a lot of noise, so extra filtering could be necessary, especially on the microphone supply. Component choice for the high-pass filter section is critical for good results, close-tolerance low-noise resistors and capacitors should be used to achieve the expected performance. Similar low-noise components should also be used in the rest of the circuit, (no carbon resistors!), though the tolerances are less critical elsewhere.

Having the microphone and loudspeaker both mounted on/in the detector itself can result in unwanted feedback limiting the volume the speaker can be used at. With the microphone mounted on the detector, simply handling the unit can cause audio output, though this can be reduced to a minimum if the unit is held firmly and moved gently. Remote mounting of the speaker and/or microphone, the use of a uni-directional microphone module (also helpful to determine where the bat is or for listening to an individual bat), or at least having the speaker facing away from the microphone, all help reduce/eliminate feedback, making it easier to share the experience with others.

Source: Bat Detector Circuit
See more : Oxygen Sensor

UltraSonic Radar [Ultrasonic Radar Circuit Board 2] This is a ultrasonic radar project with many practical applications in security and alarm systems


This is a ultrasonic radar project with many practical applications in security and alarm systems for homes, shops and cars. It consists of a set of ultrasonic receiver and transmitter which operate at the same frequency. When something moves in the area covered by the circuit the circuit’s fine balance is disturbed and the alarm is triggered. The circuit is very sensitive and can be adjusted to reset itself automatically or to stay triggered till it is reset manually after an alarm.




Adjustments
This kit does not need any adjustments, if you follow the building instructions.

Warning
If they are used as part of a larger assembly and any damage is caused, our company bears no responsibility.

While using electrical parts, handle power supply and equipment with great care, following safety standards as described by international specs and regulations.

If it does not work
Check your work for possible dry joints, bridges across adjacent tracks or soldering flux residues that usually cause problems. Check again all the external connections to and from the circuit to see if there is a mistake there.

See that there are no components missing or inserted in the wrong places.
Make sure that all the polarised components have been soldered the right way round. Make sure that the supply has the correct voltage and is connected the right way round to your circuit. Check your project for faulty or damaged components.

If everything checks and your project still fails to work, please contact your retailer and the Smart Kit Service will repair it for you.

Parts List
R1 = 180 KOhm C1, 6 = 10uF/16V TR1, 2, 3 = BC547 , BC548
R2 = 12 KOhm C2 = 47uF/16V P1 = 10 KOhm trimmer
R3, 8 = 47 KOhm C3 = 4,7 pF P2 = 47 KOhm trimmer
R4 = 3,9 KOhm C4, 7 = 1 nF IC1, 2 = 741 OP-AMP
R5, 6, 16 = 10 KOhm C5 = 10nF IC3 = 4093 C-MOS
R7, 10, 12, 14, 17 = 100 KΩ C8, 11 = 4,7 uF/16V R = TRANSDUCER 40KHz
R9, 11 = 1 MOhm C9 = 22uF/16V T = TRANSDUCER 40KHz
R13, 15 = 3,3 KOhm C10 = 100 nF D1, 2, 3, 4 = 1N4148
C12 = 2,2 uF/16V
C13 = 3,3nF
C14 = 47nF


Source: UltraSonic Radar
See More : Audio Detector

Lie Detector Circuit #2 This lie detector circuit can be built in a few minutes, but can be incredibly useful when you want to know if someone is rea

Lie Detector Circuit #2

This lie detector circuit can be built in a few minutes, but can be incredibly useful when you want to know if someone is really telling you the truth. It is not as sophisticated as the ones the professionals use, but it works. It works by measuring skin resistance, which goes down when you lie.



Parts List:

R1 - 33K 1/4W Resistor
R2 - 5K Pot
R3 - 1.5K 1/4W Resistor
C1 - 1uF 16V Electrolytic Capacitor
Q1 - 2N3565 NPN Transistor
M1 - 0-1 mA Analog Meter
MISC - Case, Wire, Electrodes (See Notes)

Notes:
  1. The electrodes can be alligator clips (although they can be painful), electrode pads (like the type they use in the hospital), or just wires and tape.
  2. To use the circuit, attach the electrodes to the back of the subjects hand, about 1 inch apart. Then, adjust the meter for a reading of 0. Ask the questions. You know the subject is lying when the meter changes.

Source: Lie Detector circuit
See more : Oxygen Sensor Simulator

Saturday, 9 October 2010

PHP Tutorial: Writing A Feedback Form Script Getting Started with PHP: Write a FormMail Script in PHP

PHP Tutorial: Writing Your First PHP Script: Feedback Form Script

by Christopher Heng, thesitewizard.com

I have always believed that the most fun way to learn a new programming language, whether it is a language like C or a scripting language like PHP, is to use it to write a real-life useful program. Of course this is not the most systematic method of learning, but it works well if you already have some background in programming.

Preliminaries

  1. Before you write your first PHP program, make sure that that your website is running on a web host that runs PHP 4.1 or above.

  2. You may also find it useful to have a copy of PHP 4.1 or later installed on your own computer. This makes testing your PHP scripts much easier. If you use Windows, you can find some tips on installing PHP on your own computer from my article on "How to Install and Configure PHP 5 to Run with Apache on Windows" at http://www.thesitewizard.com/php/install-php-5-apache-windows.shtml

  3. And of course, you will need an ASCII text editor of some kind (such as Notepad on Windows). There's a list of such editors on http://www.thefreecountry.com/programming/editors.shtml

  4. This tutorial also assumes that you have at least some knowledge of HTML. This is necessary because if I have to explain all the HTML tags as well, this tutorial will end up being tediously long.

  5. You'll probably need a bit of programming background, or at the very least, an aptitude for computer programming. Note that being able to code in HTML does not count, since HTML is not a programming language. Unlike the majority of the other articles on thesitewizard.com, this article is not targeted at the absolute newcomer. You really need background in both web design using HTML and a bit of programming skill/aptitude, otherwise this article will be indecipherable. If you are reading this article because you want to create a website, please start with How to Make / Create Your Own Website: The Beginner's A-Z Guide instead.

I will begin with a very rudimentary (but working) PHP script to take input from a feedback form and send it to you in an email message. This type of form is sometimes referred to as a FormMail or Form to Mail script. In later articles, I will develop that script (and others) to include features commonly found in such FormMail scripts.

If you are programming-savvy, you will recognize this as a sort of "Hello World" program, but infinitely more useful!

Writing the Feedback Form

The first thing we need to do is to write the feedback form itself. Put the following code in the section of an HTML file named, say, feedback.html.

Email:
Message:

Basically the form asks the visitor for his email address (the field named "email" found in input name="email" above) and message (the field named "message" found in textarea name="message"), and presents him with a button which he can click to submit the contents of the form. When the form is submitted, it is "posted" (see the "method" attribute of the

tag) to a script named "sendmail.php" (also specified in the tag).

The Feedback Form PHP Script

Now all that remains is to code "sendmail.php". This is made extremely easy by the facilities available in PHP. Type the following code into a file named "sendmail.php". Do not put anything else into that file, ie, don't put in any other HTML tags or headers, etc.

 

When the form is submitted to sendmail.php, the contents of the "email" field in the form is put into a PHP variable called $_REQUEST['email']. Likewise the contents of the "message" field is put into the variable $_REQUEST['message'].

If you had named the fields in your form "emailofsender" and "contentsofmessage", then the information submitted in those fields would have been available to your script in the variables $_REQUEST['emailofsender'] and $_REQUEST['contentsofmessage'] respectively. I think you get the idea.

The first thing we do in our PHP script is to make the information that is submitted easily accessible to the rest of the program.

Firstly, we made a copy of the contents of $_REQUEST['email'] in a variable we call $email. This was done in the line

$email = $_REQUEST['email'] ;

Note that we don't really have to call this new variable $email. We could have called it $thingamajig if we wished, but it makes sense to name a variable with some meaningful name.

Likewise, in the next line, we made a copy (assigned) of $_REQUEST['message'] in a variable $message.

$message = $_REQUEST['message'] ;

Again, we could have named the new variable anything we wanted — but it's easier for us to understand the program if the variable name reflects what it does.

The real workhorse of this script is in the line beginning with "mail".

mail( "yourname@example.com", "Feedback Form Results",   $message, "From: $email" ); 

mail is a special function in PHP that sends mail. The first parameter to mail is supposed to contain the email address you want the form contents to be sent to, such as your own email address. The second parameter is the "Subject" of the email message. The last two parameters are the content of the message and the headers you want sent, respectively. We want a "From" header so that we know who is sending the email to us and can reply to him/her if we need to.

Notice that, like many other programming languages, strings (sequences of characters) are enclosed in double quotes, such as "Feedback Form Results".

Variables like $message can be used as-is. Note also that you can also interpolate (introduce) the contents of the variable $email into a string, like "From: $email", so that if your $email string contained an address like "william@shakespeare.com", the final string that is passed to the mail function will be "From: william@shakespeare.com".

You can also use single quotes (such as those in 'Hi there') to quote strings, but when you do so, the variables included are not expanded. This is useful if, for some reason, you really want to pass the string 'From: $email' to mail without PHP translating that to "From: william@shakespeare.com".

Finally, it is appropriate to thank the visitor for his message. This is done with the line

header( "Location: http://www.example.com/thankyou.html" );

This line causes PHP to send an HTTP header back to the visitor's browser telling it to load the URL "http://www.example.com/thankyou.html". The "header" function allows us to send any HTTP header to the browser.

You will of course have to create such a file called "thankyou.html" with some sort of message to thank your visitor for his efforts, otherwise your visitor will be greeted with an unfriendly "404 File Not Found" error after he sends his message. You should also replace the URLs and email addresses with the correct ones if you want to use that script on your site.

By the way, the script has to be enclosed within the "" and "?>" tags because the PHP processor treats all input as HTML code unless otherwise specified. On most systems, you can simply use "" and "?>" as the opening and closing tags to get the script to work, however if you want to be sure that your script will work on all systems, you should use the full "" form for the opening tag.

Easy wasn't it? In just a few lines, you've written your first PHP script. And it's not some trivial and useless script — it is actually a working, usable program.

Before you put the script "live" on the Internet, check out the following additional tutorials:

  • In How to Improve Your Form to Mail Script, you will develop the script so that your visitor's input is checked to catch instances where someone accidentally clicks the "Submit" button before they fill in their email address. You will also learn how to integrate both the form and the script into a single "feedback.php" file if you wish.

  • The article How to Prevent Email Injection in Your PHP Form to Mail Scripts deals with the security aspects of putting a PHP form to mail script "live" on the Internet, where spammers can abuse it and hijack it to send spam to others.

Copyright 2000-2010 by Christopher Heng. All rights reserved.

Get more free tips and articles like this, on web design, promotion, revenue and scripting, from http://www.thesitewizard.com/

Sunday, 29 August 2010

Find the Shortest Path in C

#include <>
#include <>

#define INF 9999

void main( )
{
int arr[4][4] ;

int cost[4][4] = {
7, 5, 0, 0,
7, 0, 0, 2,
0, 3, 0, 0,
4, 0, 1, 0
} ;
int i, j, k, n = 4 ;

clrscr( ) ;

for ( i = 0 ; i < n ; i++ )
{
for ( j = 0; j < n ; j++ )
{
if ( cost[i][j] == 0 )

arr[i][j] = INF ;

else

arr[i][j] = cost[i][j] ;
}
}

printf ( "Adjacency matrix of cost of edges:\n" ) ;
for ( i = 0 ; i < n ; i++ )
{
for ( j = 0; j <>

printf ( "%d\t", arr[i][j] ) ;

printf ( "\n" ) ;
}

for ( k = 0 ; k < n ; k++ )
{
for ( i = 0 ; i < n ; i++ )
{
for ( j = 0 ; j < n ; j++ )
{
if ( arr[i][j] > arr[i][k] + arr[k][j] )

arr[i][j] = arr[i][k] + arr[k][j];
}
}
}

printf ( “\nAdjacency matrix of lowest cost between the vertices:\n” ) ;
for ( i = 0 ; i < n ; i++ )
{
for ( j = 0; j <>

printf ( “%d\t”, arr[i][j] ) ;

printf ( “\n” ) ;
}

getch( ) ;
}

Function Calls and Stack

By far the most widely used storage mediums are the floppy disks and the fixed disks (hard disks). Floppy disks and hard disks come in various sizes and capacities but they all work basically in the same way – information is magnetically encoded on their surface in patterns. These patterns are determined by the disk drive and the software that controls the drive.

Although the type of storage device is important, it is the way the stored information is laid out and managed that concerns programmers most. Therefore we would focus our attention on how information is organized and stored on the disk.

The Disk Structure

As most of us know, the disk drives in DOS and Windows are organized as zero-based drives. That is, drive A is drive number 0, drive B is drive number 1, drive C is drive number 2, etc. The hard disk drive can be further partitioned into logical partitions. Each drive consists of four logical parts-Boot Sector, File Allocation Table (FAT), Directory and Data space. Of these, the Boot Sector contains information about how the disk is organized. That is, how many sides does it contain, how many tracks are there on each side, how many sectors are there per track, how many bytes are there per sector, etc. The files and the directories are stored in the Data Space. The Directory contains information about the files like its attributes, name, size, etc. The FAT contains information about where the files and directories are stored in the data space.

When a file/directory is created on the disk, instead of allocating a sector for it, a group of sectors is allocated. This group of sectors is often known as a cluster. How many sectors together form one cluster depends upon the capacity of the disk. As the capacity goes on increasing, so also does the maximum cluster number. Accordingly, we have 12-bit, 16-bit or 32-bit FAT. In a 12-bit FAT each entry is of 12 bits. Since each entry in FAT represents a cluster number, the maximum cluster number possible in a 12-bit FAT is 212 (4096). Similarly, in case of a 16-bit FAT the maximum cluster number is 216 (65536). Also, for a 32-bit FAT the maximum cluster number is 228 (268435456. Only 28 of the 32 bits are used in this FAT). All FAT systems are not supported by all versions of Windows. For example, the 32-bit FAT system is supported only in Win 95 OSR2 version or later. There are differences in the organization of contents of Boot Sector, FAT and Directory in FAT12/ FAT16 system on one hand and FAT32 on the other.

The File Allocation Table

The File Allocation Table (FAT) maps the usage of the data space of the disk. It contains information about the space used by each individual file, the unused disk space and the space that is unusable due to defects in the disk. Since FAT contains vital information, two copies of FAT are usually stored on the disk. In case one gets destroyed, the other can be used. A typical FAT entry can contain any of the following:

- Unused cluster
- Reserved cluster
- Bad cluster
- Last cluster in the file
- Next cluster number in the file

There is one entry in the FAT for each cluster in the file area. If the value in a FAT entry doesn’t mark an unused, reserved or defective cluster, then the cluster corresponding to the FAT entry is part of a file, and the value in the FAT entry would indicate the next cluster in the file.
This means that the space that belongs to a given file is mapped by a chain of FAT entries. Each FAT entry points to the next entry in the chain. The first cluster number in the chain is the starting cluster number in the file’s directory entry. When a file is created or extended, a cluster is allocated to the file by searching the FAT for unused clusters and adding them to the chain. Vice versa, when a file is deleted, the cluster that has been allocated to the file is freed by clearing corresponding FAT entries (by setting them to 0). The FAT chain for a file ends with an entry FFFFh in the FAT.

This file occupies cluster number 3, 5, 6 and 8 on the disk. Hence the starting cluster number in the directory entry for the file is 3. Suppose this file is to be loaded into memory then OS would first load starting cluster number-3’s contents into memory. To find out the next cluster belonging to this file OS looks at entry number 3 in FAT where it finds a value 5. Therefore, now it loads the contents of cluster number 5 into memory. Once again OS looks at the FAT and finds in entry number 5 a value 6, hence it loads the contents of cluster 6 into memory. This process goes on till the OS finds an entry FFFFh in FAT, which indicates that there are no more clusters belonging to the file. Hence the process stops.

Now that we have understood how the FAT chain is traversed, let’s dig a little deeper into the FAT. The entries present in FAT are 12, 16 or 32 bits long depending on the storage capacity of the disk. Though a 12-bit FAT can handle 4096 clusters only 4078 clusters are available for use since some values are reserved. Similarly, for a 16-bit FAT out of the possible 65536 clusters that it can handle only 65518 are available for use.

In a 12-bit FAT three bytes form two entries. The first two entries (0 and 1) in the FAT are reserved for use by the OS. This means that first 3 bytes in a 12-bit FAT, first 4 bytes in 16-bit FAT and first 8 bytes in a 32-bit FAT are not used for storing cluster numbers. Out of these 3 or 4, or 8 bytes, the first byte is the media descriptor byte and the balance contains the value FFh. These balance bytes remain unused. The media descriptor byte specifies the type of the disk. It typically has a value FDh, F9h, F0h, F8h for a 360 KB, 1.2 MB, 1.44 MB and a hard disk respectively. The contents of a FAT entry are interpreted as shown below.

————————————————————————————
Values | Meaning |
————————————————————————————
12-bit | 16-bit | 32-bit | |
000h | 0000h | 0000000h | Cluster available |
FF0h-F6h | FFFFh-FFFF6h | FFFFFFFh-FFFFFF6h | Reserved cluster |
FF7h | FFF7h | FFFFFF7h | Bad cluster if not part of chain |
FF8h-FFh | FFF8h-FFFFh | FFFFFF8h-FFFFFFh | Last cluster of file |
xxx | xxxx | xxxxxxx | Next cluster in file |
————————————————————————————

Meaning of FAT entries

As we saw earlier, two identical copies of FAT are maintained on the disk. All copies are updated simultaneously whenever files are modified. If access to a FAT fails due to a read error, the OS tries the other copy. Thus, if one copy of the FAT becomes unreadable due to wear or a software accident, the other copy may still make it possible to salvage the files/directories on the disk.

Here is a program that prints the contents of the first sector of two copies of FAT for a 12-bit or a 16-bit FAT. On similar lines it can be extended to work for a 32-bit FAT.

Each disk contains two copies of FAT. In the function fat_info( ) the starting sector of each copy of FAT is determined. Next, the function read_fat_info( ) is called for reading and displaying contents of each FAT copy. Since each copy contains several entries, we have displayed only the first 16 entries for a 12-bit & 16-bit FAT. The organization of the FAT types is shown in Figure 7.3.

12-bit FAT

8 bits 8 bits 8 bits

E2 E3 O3 E1 O1 O2

16-bit FAT

8 bits 8 bits 8 bits 8 bits

E3 E4 E1 E2 O3 O4 O1 O2

32-bit FAT

8 bits 8 bits 8 bits 8 bits 8 bits 8 bits 8 bits 8 bits


E7 E8 E5 E6 E3 E4 E1 E2 O7 O8 O5 O6 O3 O4 O1 O2

For a 32-bit FAT the seven nibbles (a nibble is a group of 4 bits) E1-E2-E3-E4-E5-E6-E7-E8 form the even entry. Note that the arrangement of these nibbles is E7-E8-E5-E6-E3-E4-E1-E2 because the lower byte is always stored in memory earlier than the higher byte. This means if the value of the 4-byte FAT entry is ABCD, it would be stored as DCBA. The odd entry is represented using the set of nibbles O1-O2-O3-O4-O5-O6-O7-O8. In reality the nibble E8 and O8 don’t contribute to the cluster number since each entry in the 32-bit FAT is only 28 bits long.

On similar lines in a 16-bit FAT the four nibbles E1-E2-E3-E4 form the even entry whereas the set O1-O2-O3-O4 form the odd entry. Similarly, the even and odd entries in a 12-bit FAT are formed by E1-E2-E3 and O1-O2-O3 respectively. Picking up the values present in odd or even entries from a 32-bit FAT or a 16-bit FAT a relatively simple job. However, to pick up the values from a 12-bit FAT we have to use bitwise operators to discard one nibble out of a group of 4 nibbles. This is done in our program through the functions getfat_12( ).

/* File allocation table */

#include <>
#include <>
#include <>
#include <>
#include <>

struct boot
{
unsigned char jump[3] ;

char OEMname[8] ;

short int bps ;

unsigned char spc ;

short int reservedsec ;

unsigned char fatcopies ;

short int maxdirentries ;

short int totalsec ;

unsigned char mediadesc ;

short int secperfat ;

short int secpertrack ;

short int noofsides ;

long int hidden ;

long int hugesec ;

unsigned char drivenumber ;

unsigned char reserved ;

unsigned char bootsignature ;

long int volumeid ;

char volumelabel[11] ;

char filesystype[8] ;

unsigned char unused[450] ;

} ;

struct boot bs ;
char filetypestr[8] ;

void getfat_12 ( unsigned char * ) ;

void read_fat_info ( long ) ;

void fat_info( ) ;

void main( )
{
char choice ;

clrscr( ) ;

printf ( “A. Drive A” ) ;
printf ( “\nC. Drive C” ) ;
printf ( “\n0. Exit” ) ;

printf ( “\nEnter the drive (A/C): ” ) ;
scanf ( “%c”, &choice ) ;

if ( absread ( choice – 65, 1, 0, &bs ) == -1 )
{
printf ( “Error reading sector” ) ;
exit ( 0 ) ;
}
else
{
strcpy ( filetypestr, bs.filesystype ) ;
filetypestr[6] = ‘\0′ ;
}

fat_info( ) ;
}

void getfat_12 ( unsigned char *pfat )
{
int value ;
int *fatentry ;
int i, k ;

for ( k = 2 ; k < 18 ; k++ )
{
i = k * 3 / 2 ;

fatentry = ( int* ) ( pfat + i ) ;

if ( ( k % 2 ) == 0 )
value = ( *fatentry & 0x0fff ) ;
else
value = ( *fatentry > > 4 ) ;

printf ( “%03x “, value ) ;
if ( k % 9 == 0 )
printf ( “\n” ) ;
}
}

void read_fat_info ( long fat_num )
{
int j, i ;

unsigned char *p ;

if ( strncmp ( “FAT12″, filetypestr, 5 ) == 0 )
{
p = ( unsigned char* ) malloc ( bs.bps ) ;
absread ( 0, 1, fat_num, p ) ;
getfat_12( p ) ;
}

if ( strncmp ( “FAT16″, filetypestr, 5 ) == 0 )
{
short int *pfat ;
p = ( unsigned char* ) malloc ( bs.bps ) ;
absread ( 2, 1, fat_num, p ) ;
pfat = ( short int* ) p ;

for ( j = 0 ; j < 2 ; j++ )
{
printf ( “\n%d “, j * 8 ) ;
for ( i = 0 ; i < 8 ; i++ )
{
printf ( “%04x “, *pfat++ ) ;
}
}
}
}

void fat_info( )
{
long int first_fat, second_fat ;

first_fat = bs.reservedsec ;
second_fat = bs.reservedsec + bs.secperfat ;

printf ( “\n%s Fat Information”, filetypestr ) ;
printf ( “\n——————————-” ) ;

printf ( “\nFirst FAT Information\n” ) ;

read_fat_info ( first_fat ) ;

printf ( “\n\nSecond FAT Information\n” ) ;

read_fat_info ( second_fat ) ;
printf ( “\n——————————-\n” ) ;
}

VIA : http://www.c-cplusplus.com/fat-exploring-the-disk

Tower Of Hanoi in c

Tower of hanoi is a historical problem, which can be easily expressed using recursion. There are N disks of decreasing size stacked on one needle, and two other empty needles. Tower of hanoi is required to stack all the disks onto a second needle in the decreasing order of size. The third needle can be used as a temporary storage. The movement of the disks must confirm to the following rules,

1. Only one disk may be moved at a time
2. A disk can be moved from any needle to any other.
3. The larger disk should not rest upon a smaller one.

/* Program of towers of hanoi. */

#include <>
#include <>

void move ( int, char, char, char ) ;

void main( )
{
int n = 3 ;

clrscr( ) ;

move ( n, ‘A’, ‘B’, ‘C’ ) ;

getch( ) ;
}

void move ( int n, char sp, char ap, char ep )
{
if ( n == 1 )
printf (“\nMove from %c to %c “, sp, ep ) ;
else
{
move ( n – 1, sp, ep, ap ) ;
move ( 1, sp, ‘ ‘, ep ) ;
move ( n – 1, ap, sp, ep ) ;
}
}