Here it is:
[insert]
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int search (char *a, char b);
int isequals(char *a, char *b);
int issmaller(char *a, char *b);
int isgreater(char *a, char *b);
char atpos(char *a, int loc);
char* getsub(char *a, int loc, int len);
char str4[20];
int main(void)
{
char str[20] = "Rohan is a good boy";
char str1[20] = "Roh";
char str2[20] = "Rohan is a good boy";
char str3[20] = "Sohan";
char *sub;
char s;
int result;
char *a, *b;
//printf("\nEnter a character to search");
//scanf("%c", &s);
/*result = search(str, s);
if(result == 1)
printf("\n Char found");
else
printf("\n Char not found");
*/
/*result = isequals(str, str1);
if(result == 1)
printf("\n Char found");
else
printf("\n Char not found");
*/
/*
result = issmaller(str, str1);
if(result == 1)
printf("\n 1st string smaller");
else
printf("\n Not smaller");
result = isgreater(str3, str1);
if(result == 1)
printf("\n 1st string greater");
else
printf("\n 1st string not greater");
*/
/*
s = atpos(str, 0);
if((s >= 65 && s < 91) || (s >= 97 && s < 122))
printf("\nChar is %c",s);
else
printf("\nYou are trying more than the lenght");
*/
sub = getsub(str, 2, 4);
printf("\n%s", sub);
return 0;
}
char* getsub(char *a, int loc, int len)
{
int lenstr;
int pos= 0, i,j;
for(i = 0;i< 20;i++)
str4[i] = NULL;
lenstr = strlen(a);
for(pos = 0;pos< loc;pos++)
{
a++;
}
for(i =0; i<len;i++)
{
str4[i]= a;
a++;
}
str4[++i] = '\0';
return str4;
}