Skip to main content

A program closely resembles to the one used by Adobe Reader

Ultimately, this is a program for searching strings.This program enables us to give a key string to be searched in given set of sentences. The output will be the position at which the given string is present.This can be improved in the C++ platform to exactly mention the string as selected. 


//A Search program closely resembles to the one used by Adobe Reader.

#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<string.h>
class para
{
public: char ckey,skey[10],sent[40];
int i;
void get()
{
cout<<"Type the paragraph of maximum 40 characters, press enter to finish:\n------------------------"<<endl;
gets(sent);
cout<<"---------------------------------------------\nput the letter to be searched:";
cin>>ckey;
cout<<"type the string to be searched:";
gets(skey);
cout<<"processing...\n";
}
void check();

};
void para::check()
{
int l=strlen(sent);
cout<<"\n-------------------------------------\n Length of ur data="<<l;
cout<<" '"<<ckey<<"' is present at the following positions:";
int flagc=0;
int flags=0;

for(i=0;i<l;i++)
{
if(sent[i]==ckey)
{
cout<<" "<<i+1<<"\t";
flagc++;
}
}
if(flagc==0) cout<<endl<<" '"<<ckey<<"' is not present!";
else cout<<endl<<" total occurence ="<<flagc;
cout<<"\n\n--------------------\n\n";

cout<<"The string '"<<skey<<"' starts at the following positions\n";
int j,x,y,t=0;
int lk=strlen(skey);
for(i=0;i<lk;i++)
{
for(j=0;j<l;j++)
{
if(skey[i]==sent[j])
{
x=i;
y=j;
flags=0;
for(x,y;x<lk,y<j+lk;x++,y++)
{
if(skey[x]!=sent[y]) break;
else
{
flags++;
if(flags==lk)
{
cout<<j+1<<"\t";
t++;
}
}
}

}
}
}
cout<<"\n\n total occurence ="<<t;
};
void main()
{
clrscr();
para obj;
obj.get();
obj.check();
getch();
}


Have U tried this?

Comments

Popular posts from this blog

Talky Messenger Documentation & Setup

( Github ) Just created a chat app that runs in Node and Socket. the attempt was worthy. Talky is a messenger app built with Node, Express, Socket, Angular & Bootstrap. It's like a server-client structure. (But obviously not like the one we done at OS lab using shared memory). It has a broadcasting structure. Talky does not keep a log on chat. i.e., It doesn't have a memory or database. When we close the browser window, chat history is lost. There I also added a basic console, protected by a password, to send real-time notifications to active clients. The name 'Talky' was suggested by a friend of mine. (hey, thank you for that. The fact is that I am not really good at naming...😝) What if sometimes your college blocks WhatsApp? Try Talky. ( There is also a website on internet in the name of 'Talky' which has no connection with this one. ) Download Talky Messenger To use Talky, all you need is 3 things: Node server Source code...

Connecting Kerala's Call of Duty Warzone Community: Find Your Squad!

Namaskaram f ellow Warzone fanatics! Tired of dropping into Verdansk only to be met with a chorus of confused comms and random grenades? I feel your pain. Finding a squad that speaks your language (literally and figuratively) can be tougher than surviving a gas zone with only a pistol. That's why I've built this little corner of the internet – a rallying point for all the Malayalam-speaking Warzone warriors of Kerala! warzonekerala.com Why Join the Kerala Warzone Group? (More Than Just a Game): Let's face it, Warzone isn't just about shooting and looting. It's about camaraderie, shared victories, and the glorious "poda mone dinesha" moments. Here's why joining our community is a game-changer: Bhasha Bliss: Finally, a squad where you can strategize in crystal-clear Malayalam! No more frantic hand gestures or Google Translate mishaps. Coordinate drops, call out enemies, and celebrate wins in your mother tongue. Kerala Connection: Connect with ...

How to install Node.js

Installing Node in Windows Installing node in Windows is pretty easy. To install Node you should be aware of your Windows bit version(32-bit / 64-bit). To know that, right click 'computer'>Properties. There you will find the bit version of the OS you are using. Now you know about the version of the OS you are using. - Head to nodes official website ( nodejs.org ) and download the msi for your version. - I recommend opting the LTS version of node. (if you have any suggestions, let me know.) - Install node with default recommended configuration. Installing Node in Linux/ Ubuntu This article will help you :  https://nodejs.org/en/download/package-manager/ If you don't have curl in your system, use terminal to: sudo apt-get update sudo apt-get install curl Source:  http://askubuntu.com/questions/259681/the-program-curl-is-currently-not-installed