#include<stdio.h> // Library Function which can be used for the String Mnpltn
#include<string.h>
#include<conio.h>
void main()
{
int ch;
clrscr();
printf("MAIN MENU"); // Main Menu
printf(" \n\n1. String Manipulation With Library Function\n\n2. String Manipulation Without Library Function\n\n Enter the Choice : ");
scanf("%d",&ch);
if(ch==1)
{
char a[20]; //With Library Function
int i;
clrscr();
gets(a);
i=0;
while(a[i]!='\0')
i++; //counts no of chars till encountering null char
printf(sring length=%d,i);
}
else if(ch==2)
{
// Without Library Function
int length;
char cstring[20];
printf("\n\nEnter the Charcter :")
gets(cstring);
for (length = 0; cString[length]; ++length); //length now holds the length of cString
printf("Length = ",length)
}
else
{
printf("\nWrong option");
getch();
}
Regards,
Sahil
No comments:
Post a Comment