I'm trying to use a for loop to go through two strings character by character and see where they are equal, where they are different, and if so if both are letters than I do one condition, but if one is a letter and one is an underscore, then I do something else. The first part of the loop works fine; it can tell when the two values are equal. However, when I use isalpha to see if they are both different letters, then it doesn't do it.
#include <stdio.h>
#include <string.h>
#include <ctype.h>
char s1[] = "v_intner_";
char s2[] = "wri_t_ers";
char* getTranscript(char* s1, char* s2){
int i;
char sOneTemp[9];
char sTwoTemp[9];
char eTranscript[9];
strcpy(sOneTemp, s1);
strcpy(sTwoTemp, s2);
for(i=0; i<9; i++){
if(sOneTemp[i]==sTwoTemp[i]){
printf("Those two characters are equal.\n");
}
if(sOneTemp[i]!=sTwoTemp[i]){
if(isalpha(sOneTemp[i]) && isalpha(sTwoTemp[i])){
printf("Both are letters\n");
}
else{
printf("One is a dash\n");
}
}
}
printf("The value of s1 is: %s\n", sOneTemp);
return s1;}
main()
{
printf("The main method returns: %s", getTranscript(s1,s2));
return 0;
}