Our website is made possible by displaying online advertisements to our visitors.Please consider supporting us by disabling your ad blocker.
Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu
Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Translate it in your own Language

Print this Job Post

Print Friendly and PDF

Friday, May 30, 2014

strlwr, strupr in c

Here we will change string case with and without strlwr, strupr functions.

strlwr in c

#include <stdio.h>
#include <string.h>
#include<conio.h> 
void main()
{
    char string[] = "Strlwr in C";
    clrscr();
    printf("%s\n",strlwr(string));
    getch();
}

strupr in c

#include <stdio.h>
#include <string.h>
#include<conio.h>
void main()
{
    char string[] = "strupr in c";
    clrscr();
    printf("%s\n",strupr(string));
    getch();
}

Change string to upper case without strupr

#include <stdio.h>
#include<conio.h> 
void upper_string(char*);
void main()
{
   char string[100];
   clrscr();
   printf("Enter a string to convert it into upper case\n");
   gets(string);
   upper_string(string);
   printf("Entered string in upper case is \"%s\"\n", string);
   getch();
}
void upper_string(char *string)
{
   while(*string)
   {
       if ( *string >= 'a' && *string <= 'z' )
       {
          *string = *string - 32;
       }
       string++;
   }
}

Change string to lower case without strlwr

#include <stdio.h>
#include<conio.h> 
void lower_string(char*);
void main()
{
   char string[100];
   clrscr();
   printf("Enter a string to convert it into lower case\n");
   gets(string);
   lower_string(string);
   printf("Entered string in lower case is \"%s\"\n", string);
   getch();
}
void lower_string(char *string)
{
   while(*string)
   {
      if ( *string >= 'A' && *string <= 'Z' ) 
      {
         *string = *string + 32;
      }
      string++;
   }
}

No comments:

Post a Comment

Copyright @ CrackMNC 2014-2024
Divas Nikhra Theme by Crack MNC