char * strsub(char*,int,int);
void main()
{
    char s[20];
    int pos,n;
    char str1[33];
    clrscr();
    printf("enter the string-->");
    gets(s);
    printf("enter the starting position-->");
    scanf("%d",&pos);
    printf("enter the ending position-->");
    scanf("%d",&n);
    strcpy(str1,strsub(s,pos,n));
    printf("%s",str1);
    getch();
}
char * strsub(char *p,int pos,int n)
{
    int a=0,i=0;
    char *s1;
    while(a!=pos)
    {
        p++;
        a++;
    }
    while(i!=n)
    {
        *s1=*p;
        p++;
        i++;
        s1++;
    }
s1-n;
printf("%s",*s1);
return(&s1[0]);
}

No tags Hide

int stridx(char*,char);
void main()
{
char s[40];char ch;int h;clrscr();
printf("\n enter vstring-->");
gets(s);
printf("enter character to find in string--->");
scanf("%c",&ch);
h=stridx(&s[0],ch);
printf("position is=%d" ,h);
getch();
}
int stridx(char *x,char ch)
{
int j,i=0;
     for(j=strlen(x);j>=0;j--)
         {
          if(x[j]==ch)
           {  i++;
           return(strlen(x)-j);
     }            }

     {return(-1);}
}
/*

No tags Hide

struct book
{
    char name[50];
    char author[80];
    int callno;
};
void main()
{
    struct book b1={"let us c","raman bhai vhora",9727593201};
    struct book *ptr;
    clrscr();
    ptr=&b1;
   
    printf("\nname=%s,\nauthor=%s,\ncallno=%d",ptr->name,ptr->author,ptr->callno);
    getch();
}

No tags Hide

void main()
{
    int a[10],i;
    int *b;
    void show (int*,int);
    clrscr();
    for(i=0;i<=9;i++)
         scanf("%d",&a[i]);
    show(a,9);
    getch();
}
void show(int*b,int x)
{
    int i;
    for(i=0;i<=x;i++)
    {
        printf("\n value is=%d",*(b+i));
    }

getch();
}
/*

No tags Hide

void main()
{
    FILE *fp,*fp1;
    char x[50],y[50];
    clrscr();
    fp=fopen("d:\\j1.txt","r");
    fp1=fopen("d:\\j2.txt","r");
    if(fp==NULL)
    {
        printf("can't open");
    }
    if(fp1==NULL)
    {
        printf("can't open");
        fclose(fp);
        exit();
    }
    fgets(x,49,fp);
    fgets(y,49,fp1);
    {
    if(strcmp(x,y)==0)
    {
        printf("both file are same");
    }
    else
    {
        printf("both file are not same");
        printf ("\n%s",x);
        printf ("\n%s",y);
    }}
fclose(fp);
fclose(fp1);
getch();
}

No tags Hide

Next »

Managed by

MNP INFOTECH