I need the code to implement those two functions;
myStrCmp
Compares two strings, returns true if equal and false otherwise
int myStrCmp(char* str1, char* str2)
myStrNCpy
Copies N characters from str2 to Str1
void myStrNCpy(char* str1, char* str2, int n)
please help me
this is the code of the first fucntion ...where is the error?
myStrCmp
Compares two strings, returns true if equal and false otherwise
int myStrCmp(char* str1, char* str2)
myStrNCpy
Copies N characters from str2 to Str1
void myStrNCpy(char* str1, char* str2, int n)
please help me
this is the code of the first fucntion ...where is the error?
Code:
#include<stdio.h> #include"myString.h" int main (){ char* str1; char* str2; char result; printf("Enter string1:\n"); scanf("%s",str1); printf("Enter string2:"); scanf("%s",str2); result=myStrCmp(str1,str2); if(result==1) printf(" same"); else printf(" different"); } int myStrCmp(char* str1, char* str2){ int i; if (myStrLen(str1) - myStrLen(str2)) return(1); for ( i = 0 ; i < myStrLen(str1) ; i++ ) { if (*(str1+i) - *(str2+i)) return(1); } return(0); }
Comment