Saturday, November 13, 2010

Two String functions in C using Pointers.

Getting back to what I love the most C Programming using Pointers.

StringPointers.c


#include<stdio.h>
#include<conio.h>
int strlen(char s[]);
void strcat(char src1[],char src2[],char dest[]);
void main()
{
int l;
char *str;
char s1[50],s2[50],s3[100];
clrscr();
gets(str);
l=strlen("Apple");
printf("\n%d",l);
l=strlen(str);
printf("\n%d",l);
printf("\nEnter s1 = ");
gets(s1);
printf("\nEnter s2 = ");
gets(s2);
strcat(s1,s2,s3);
printf("\n%s",s3);
getch();
}
void strcat(char src1[],char src2[],char dest[])
{
while((*dest++=*src1++)!='\0')
;
dest--;
while((*dest++=*src2++)!='\0')
;
}
int strlen(char s[])
{
int n=0;
while(*s++!='\0')
n++;
return(n);
}


To be continued . . .

2 comments:

  1. Hot to insert image in panel in java ...........

    ReplyDelete
  2. HI Sir,

    How to convert PDF into PPT.
    or how to create Power point using Java,VB Script

    ReplyDelete