I'm making an "acronym maker" where a string is inputted and ran through with a loop to find capitalized letters and move the data into a separate "acronym" string. when I run this I get asked for string input on the acronym but fgets() does not run and the acronym printf prints something completely random such as "Acronym of " " is " ASXXXFFP". it seems the amount of rows in the string works completely fine as I will get this output as many times as rows declared. I also get asked for input if the R value is more than one, but never on the first row stringA[0]. In my head, this seemed like reasonable code.
#include <stdio.h>
#include <string.h>
int main() {
// declaring R as the variable for rows of array
int R;
printf("Enter the number of acronyms to add to the database: ");
scanf("%d", &R);
char stringA[R][50];
char stringB[R][7];
// starting for loop to run this code for each row of the string arrays
for(int i=0; i<R; i++){
// declaring b for use when scribing values in string[i] columns
int b = 0;
// asking for input on stringA[i]
printf("\nEnter the string to convert into an acronym: ");
fgets(stringA[i], 50, stdin);
// after the input, running a loop for each character or 'column' in the current focused row
for(int j=0; j<50; j++){
// if the character is capitalized, the ascii values should pick it up in this if statement
if(stringA[i][j] >= 'A' && stringA[i][j] <= 'Z'){
//scribing the capitalized single character into a spot in the stringB for acronyms, incrementing b
stringB[i][b] = stringA[i][j];
b++;
}
}
// trying to print statement
printf("Acronym of %50s is %7s", stringA[i], stringB[i]);
}
}
i tried changing fgets to scanf, i tried using intermediary strings and using strcpy, i am stuck.I have no real immediate errors or warnings in the compiler. I don't see where to go from here honestly.