Hi,
I have a problem in writing a code using pointer.My assignment is to create a function that compre 2 strings by using a pointer.It returns 1 if they are different and 0 if they are the same.I come up with the following code,but i cann't implement pointer ,please help me in modifying it.The existing code has some bugs but i couldn't identify where is it
I have a problem in writing a code using pointer.My assignment is to create a function that compre 2 strings by using a pointer.It returns 1 if they are different and 0 if they are the same.I come up with the following code,but i cann't implement pointer ,please help me in modifying it.The existing code has some bugs but i couldn't identify where is it
Code:
void main() {
char str1;
char str2;
cout<<"Enter the first string";
cin>>str1;
cout<<"Enter the second string";
cin>>str2;
compstr(str1,str2);
}
void compstr(char s1,char s2){
if(strcmp(s1,s2)==0){
return 1;
else
return 0;
}
Comment