#include<stdlib.h>
#include<stdio.h>
void copy (char *x , char *y);
void merge(char *x , char *y);
void comp( char *x , char *y);
main()
{
char ch,*ptr,*ptr2;
ptr=malloc(20 * sizeof(char));
ptr2=malloc(20 * sizeof(char));
do
{
printf(" 1-Merge\n 2-Copy\n 3-Cmpare\n 4-exit\n");
scanf("%d",&ch);
}while(ch > 4 || ch <1);
if(ch==1)
{
printf("Enter 1st string:\n");
scanf("%s",ptr);
printf("\n string 2 :\n");
scanf("%s",ptr2);
merge(ptr,ptr2);
}
else if (ch == 2)
{
printf("Enter 1st string:\n");
scanf("%s",ptr);
printf("Rezult\n");
copy(ptr,ptr2);
}
else if ( ch == 3)
{
printf("Enter 1st string:\n");
scanf("%s",ptr);
printf("\n string 2 :\n");
scanf("%s",ptr2);
printf("Rezult\n");
comp(ptr,ptr2);
}
else if(ch == 4)
{
puts("bey bey");
}
else
{
printf("somthing went wrong");
}
}
void copy (char * x , char * y)
{
y=x;
printf("the string is=%s",y);
}
void merge(char * x , char * y)
{
printf(" merged string = %s %s",x,y);
}
void comp( char * x , char * y)
{
if(*(x)==*(y))
{
printf("strings are compatible");
}
else if ( *(x) != *(y))
{
printf("strings aren't compatible");
}
}عندي مشكلتين
الاولي:
void copy (char * x , char * y)
{
y=x;
printf("the string is=%s",y);
}ابلغني شخص في planet-source-code بان هناك عيب في هذه الداله
وهو ان انا هنا x=y اسندت اول عنوان من الاول الي الثاني فقط وانني لم ااخذ copy من النص
ثانيا
void copy (char * x , char * y)
{
y=x;
printf("the string is=%s",y);بالفعل هذا ما اكتشفته قبل ان يبلغني به وهو ان هذه الداله فقط تقارن اول حرف من كل سلسله
لانها بالفعل تقارن القيمه المخزنه في ادني عنوان للمؤشرين
هل هناك من شخص يفيدني؟
والف شكر ليكم علي تعبكم معي
B)