Thursday, May 31, 2012

String Sorting Program in C (uses array of pointers to store strings)

/* string sorting program the logic may be simple but I have used array of pointers here to store the strings
crucial here is u should you malloc and calloc to get 
correct output(because array of pointers are used)*/ #include stdio.h #include string.h #define MAX 50 void main() { char *names[MAX],*dummy; int i=0,j=0,n=0; clrscr(); puts("enter no. of strings you want to enter"); scanf("%d",&n); printf("please enter %d strings\n\n",n);

Sunday, May 27, 2012

Scramble word finder- C program

/* C program for SCRAMBLE word finding
Download a wordlist.txt file on internet which consists of
all possible english words and save it in your program folder
before running the program. */


#include stdio.h #include string.h void main() { FILE *fp; char scramble[12],word[18],dummy[18],c; int i=0,j=0,wordLen,wordLenS,count=0; clrscr(); fp=fopen("wordlist.txt","r"); printf("enter scrambled word--"); scanf("%s",scramble); wordLenS=strlen(scramble);

Wednesday, May 16, 2012

Pattern Finder in all DIRECTIONS in a GRID of numbers -C program

/* Pattern Finder in all DIRECTIONS in a GRID of numbers -C program
you are allowed to enter a pattern of any length then the ROW and
COL of the pattern occurence is shown in the output.
pattern is searched in ALL THE EIGHT DIRECTIONS */


#include stdio.h #include string.h short int checkPattern(int,int,int); short cp[8][8]={5,4,1,2,3,4,5,6, 6,3,1,2,3,4,5,5, 5,7,5,3,5,1,3,1, 4,1,7,4,3,4,5,1, 3,2,3,4,5,1,5,2, 2,2,5,2,1,4,1,3, 1,4,7,8,6,5,4,4, 6,5,3,2,6,7,8,5}; char p[5]; void main() { int i,j,k;

Friday, May 11, 2012

Password STRENGTH and VALIDITY checking C program

/* password Strength and Validity checking C program-

This program takes your password and checks weather its valid
are not.
If valid then its checks the password strength and gives
one of the following result : LOW, MEDIUM, HIGH, VERY HIGH.


note-this is my algorithm(most followed), you can change as you need.
*/


#include stdio.h #include conio.h #include string.h #define SIZE 32 short int checkValid(char*); void checkStrength(char*); short int alphabetCount=0, digitCount=0; short int length=0; short int symbolCount=0; //to count symbols like ;'./ etc void main() { char pw[SIZE],c; short int count,error,i=0; clrscr();

Sunday, April 29, 2012

PASSWORD entry model- C program

// program for how **** are displayed when you type anything
// in the PASSWORD box


#include stdio.h #include conio.h int main() { int i=0; char ch,pass[10]; clrscr(); puts("enter password (max 10 characters wide) \n"); puts("only digits and characters are allowed "); puts("\n enter here- "); while((ch=getch())!='\r') //until ENTER is pressed { if(isalnum(ch)) { putchar('*'); pass[i++]=ch; } } pass[i]='\0'; printf("\n entered password is- %s",pass); getch(); return 0; }

Tuesday, April 24, 2012

RFID based Attendance system using 8051- with easy AUTOMATIC FILE generation facility


watch the video for explanation of the project

#include
 #include<string.h>
 #include "lcd_display4bit.h"

 #define TOTAL 5

 void serial_init();
 void serial_txS(char *);
 void serial_tx(char);
 void checkID();
 void printOnTerminal();
 short int checkTodaysAttd(int);

 sbit ON=P1^0;
 sbit RESET=P1^1;
 sbit result=P1^2;
 sbit IR_Tx=P1^3;
 sbit IR_Rx=P1^4;
 sbit Reset_Todays_Attendence=P1^5;
 
struct details
 {
   char *name;
   char id[4];
   int count;
 }emp[TOTAL]={{"phanindra", "437p", 0},
          {"nayak",     "455n", 0},
          {"anilKumar", "414a", 0},
          {"gowtham",   "456g", 0},
          {"chaitu",    "449c", 0}};

 char recieved_id[4]={0};
 int i, no_of_stu=0, todays_count=0;
 int todays_ids[4]={0};
 short int access=0, gotID=0;

 void serial() interrupt 4
 {
   EA=0;
     for(i=0;i<4;i++)
      {
        while(RI==0);
        recieved_id[i]=SBUF;
        RI=0;
      }
      gotID=1;
   EA=1;
 }

//***********************************------
 void main()
  {
    ON=RESET=result=1;
    rs=en=0;
    P2=0x00;
    IR_Rx=1;
    IR_Tx=0;
    EA=1;
    ES=1;
    serial_init();
    lcd_init();

super:    
   while(1)
     {
     IR_Tx=0;
     lcd_cmd(0x01);

       while(!ON)
       { 
        lcd_cmd(0x01);
        IR_Tx=1;
         while(!(IR_Rx==1))
         {
          lcd_cmd(0x01);
          lcd_dataS("ID please");
          
          while(gotID==0)   //wait until any card is shown
            if(ON==1) goto super;
          
          checkID();    
         }
       }
      /////////////////////////
       while(!result)
        {
          for(i=0;i<=TOTAL;i++)
          {
            lcd_cmd(0x01);
            lcd_dataS(emp[i].name);
            lcd_cmd(0xc0);
            lcd_data_int(emp[i].count);
            delay_msec(500);
          }
        }
      ////////////////////////

       while(! Reset_Todays_Attendence)
        {
          for(i=0;i'\0';

          todays_count=0;
          lcd_cmd(0x01);
          lcd_dataS("todays attd rst");
          delay_msec(100);
        }
      ///////////////////////
      }    //end of super loop
 } //end of main

//*************************************

void checkID()
{
  access=0;               //like a flag
  lcd_dataS(recieved_id);
    for(i=0;iif(( strcmp(emp[i].id , recieved_id) )==0)
     { 
      if(checkTodaysAttd(i)) 
          {
              access=1;
              lcd_cmd(0x01);
              lcd_dataS("welcome");
              lcd_cmd(0xc0);
              lcd_dataS(emp[i].name);
              emp[i].count++;

            todays_ids[todays_count]=i+1;
                 todays_count++;

            delay_msec(400);
              printOnTerminal();
            gotID=0;
              break;
          }
       else
         {
           lcd_cmd(0x01);
           lcd_dataS("your turns over");
           gotID=0;
           delay_msec(400);
         }
     }
    }


   if(access==0)
    {
        lcd_cmd(0x01);
        lcd_dataS("access denied");
        delay_msec(100);
        gotID=0;
    }    
}

short int checkTodaysAttd(int id)
{
  short int d;
  for(d=0;dif(id==(todays_ids[d]-1))
    return 0;    //return 0 if specific ID has already been
  }               //counted for today.
  return 1;
}

void printOnTerminal()
{ EA=0;
  serial_tx('\r');
  serial_tx('\n');
  serial_txS(emp[i].name);
  serial_tx(' ');
  serial_txS(emp[i].id);
  serial_tx(' ');
  serial_tx(emp[i].count+48);
  EA=1;
}  

void serial_init()
{
  TMOD=0x20;
  TH1=0xfd;
  SCON=0x50;
  TR1=1;
}

void serial_txS(char *p)
{
  while((*p)!='\0')
  {
    SBUF=*p;
    while(TI==0);
    TI=0;
    p++;
  }
}

void serial_tx(char x)
{
  SBUF=x;
  while(TI==0);
  TI=0;
} 

Thursday, April 5, 2012

Searching WORD and its COUNT in a FILE - C program


string Searching in a FILE- C program
count of the appearances 
/* program for searching a keyword in a FILE.
   program also tells the number of matches */


 #include "stdio.h"  
 #include "string.h"
 #include "ctype.h"

 void main()
 {
   FILE *fp;
   char keyword[15]={0},c;
   int i,length,count=0;
   clrscr();