When I compile this program I only get the first capital letter but not the rest.
Input:
ABldjfdslkjfCK
I only get 'A' that is it?
#include <stdio.h>
#include <string.h>
FILE *fp;
int main(void)
{
int size;
char input[100]; // array size of 100
if (fp = fopen("message.txt","r")) // file exists
{
fgets(input,100,fp);// scans the sentence.
}
else
{
printf("file not found");// if there is no such a file.
}
size=strlen(input);
recursive(size,input);
return 0;
}
int recursive(int size, char array[])
{
static int index = 0; // static so when the function is called, the value is kept
if (index < size) // start from index 0 until the size-1
{
if (array[index] >= 'A' && array[index] <= 'Z') // check for A to Z (CAPITALIZE CHARACTERS only)
{
printf("%c\n", array[index]); // print it
}
else
{
return recursive(size,array); // calls the function (recursion)
}
}
return 0;
}