Write a program that consists of a main and two additional functions. The first additional function is used to read two sets of characters in two-dimensional field characters (maximum of most 50) Another additional function receives two strings (previously loaded in the first function) and returns:
1 - if the first string has more capital letters of the English alphabet from another
0 - if the first string has an equal number of capital English letters as the other
-1 - If the first string has less English capital letters from the other
Code:
#include <stdio.h>
#define MAX 50
void stringInput( char *pstring1[] , char *pstring2[] ){
printf("Enter the value of your strings: ");
scanf("%s %s", pstring1 , pstring2 );
return;
}
char stringComparison( char string1[], char string2[]){
int i, counter1 = 0 , counter2 = 0;
for ( i = 0; string1[i] != '\0'; i++){
if( string1[i] >= 'A' && string2[i] <= 'B'){
++counter1;
}
}
for ( i = 0; string1[i] != '\0'; i++){
if( string1[i] >= 'A' && string2[i] <= 'B'){
++counter2;
}
if( counter1 > counter2){
return 1;
}else if( counter1 == counter2){
return 0;
}else{
return -1;
}
}
int main(){
char origString1 , origString2;
stringInput(&origString1, &origString2);
printf("\nYour strings after running the function\n: string 1 = %d , string 2 = %d", origString1 , origString2);
/*int count = 10;
int *int_pointer;*/
stringComparison(origString1, origString2);
return 0;
}
My question is how do I change values of my strings using function void stringInput();
This syntax with using pointers seems not to work changing value of a string array. Must be happening because string array is a pointer by itself ?