You feel excited to learn computer languages

Then you are at the right place. Computer languages are most fun thing you have ever seen. Use this excellent languages and have a nice future...

How computer can help you?

I will ask how it can not? From the latest trend of social networking sites like Facebook, Twitter to the extended use of computer in our house hold devices. You can be benefited from computer in the every aspect of life.

What web technology?

It is the blessings of web technology, that brings you here and you are reading my post now. Strange huh!! Not at all. Use my web technology tutorials and understand, how they can help you for better marketing and advertising systems.

How Mobile technology can help us?

You have answer right? I know. But in my tutorials I will cover some unique features that may add some information in your hard disk too. Sounds good? Check them...

Computer and future

Yes that is the most important question to me. What is next? What is going to be the next big thing for us? Well I will answer them in my blog. Check the corresponding section..

Showing posts with label string functions in C. Show all posts
Showing posts with label string functions in C. Show all posts

Sunday, November 6, 2011

String Programming in C language

This program covers almost every String operations available in C Language


#include<conio.h>
#include<stdio.h>

 void main()
 {
    char arr[10],ar[10],ar1[]="HiQwwerDr";
    int r;
    int cmp(char *,char *);
    void mid(char [],char [],int,int);
    void toup(char []);
    void tolow(char []);
    void toggle(char []);
    void reverse(char [],char []);
    clrscr();
    printf("Enter the word ");
    scanf("%s %s",arr,ar);
    /*r=cmp(arr,ar);
    if(r==0)
    printf("This two words are same");
    else
    printf("This two word are not same");
    printf("\nThe size of first word is %d\n",scount(arr));
    mid(arr,ar,2,5);
    printf("%s",ar);
    toup(arr);
    printf("\n%s",arr);
    tolow(arr);
    printf("\n%s",arr);
    toggle(ar1);
    printf("\n%s",ar1); */
    reverse(arr,ar);
    printf("\n%s",ar);
    getch();
 }
 int scount(char *arr)
 {
int i=0;
while(*arr!=NULL)
{
i++;
arr++;
}
return i;
 }
 int cmp(char *arr,char *ar)
 {
while(*arr!=NULL)
{
if(*arr==*ar)
{
arr++;
ar++;
}
else
return 1;
}
return 0;
 }
 void mid(char arr[],char ar[],int s,int e)
 {
int i,
j=0;
i=s-1;
while(arr[i]!=NULL && i<=(e-1))
{
ar[j]=arr[i];
i++;
j++;
}
ar[j]=NULL;
 }
 void toup(char arr[])
 {
int i=0;
char ch;
while(arr[i]!=NULL)
{
ch=arr[i];
if(ch>=97 && ch<=122)
ch-=32;
arr[i]=ch;
i++;
}
 }
 void tolow(char arr[])
 {
int i=0;
char ch;
while(arr[i]!=NULL)
{
ch=arr[i];
if(ch>=65 && ch<=90)
ch+=32;
arr[i]=ch;
i++;
}
 }
 void toggle(char arr[])
 {
int i=0;
char ch;
while(arr[i]!=NULL)
{
ch=arr[i];
if(ch>=65 && ch<=90)
ch+=32;
else if(ch>=97 && ch<=122)
ch-=32;
arr[i]=ch;
i++;
}
 }
 void reverse(char arr[],char ar[])
 {
int i,j=0,k;
i=scount(arr);
k=i-1;
while(j<=(i-1))
{
ar[j]=arr[k];
j++;
k--;
}
ar[j]=NULL;
 }