hi,
well here is a newbie's question. What is wrong with this program. I am writing a function to perform strcpy:
#include <stdio.h>
#include <string.h>
#include <conio.h>
void xstrcpy(char *s);
int main()
{
char s[80];
printf("Enter the string\n");
scanf("%s",s);
xstrcpy(s);
getch();
return 0;
}
void xstrcpy(char *s)
{
char s1[80];
while(*s!='\0');
{
*s1=*s;
s1++;
s++;
}
*s1='\0';
printf("S1 = %s",s1);
}
and this one which gives me an error in the exit function. I am using borland C++ 5.5 compiler.
#include <stdio.h>
#include <string.h>
void xstrcmp(char *s1, char *s2);
int main()
{
char s1[80],s2[80];
printf("\n Enter the first string");
scanf("%s",s1);
printf("\n Enter the second string");
scanf("%s",s2);
xstrcmp(s1,s2);
return 0;
}
void xstrcmp(char *s1, char *s2)
{
while(*s1!='\0')
{
if(*s1==*s2)
{
s1++;
s2++;
continue;
}
else
{
printf("\nDifferent");
exit();
}
}
printf("\nSame");
}
Please help
![]()



LinkBack URL
About LinkBacks



