I am trying to create a function that capitalises all chars in an array.
#include <stdio.h>
#include <string.h>
void capitaliser(char inputText[])
{
int counter;
char upperLetter;
char lowerLetter;
for (counter = 0; counter < 26; counter++)
{
lowerLetter = 'a';
for (char upperLetter = 'A'; upperLetter <= 'Z'; upperLetter++)
{
if(inputText[counter] == lowerLetter)
inputText[counter] = upperLetter;
lowerLetter++;
}
}
}
int main( void )
{
int counter;
char array1[26]; = {'\0'};
char array2[26]; = {'\0'};
scanf("%s %s", array1, array2);
capitaliser(array1[26]);
capitaliser(array2[26]);
for ( counter = 0; counter < 26; counter++ )
{
printf("\n%c %c", array1[counter], array2[counter]);
}
}
When the code from the function is placed in main and 'inputText' is replaced with either 'array1' or 'array2' the program runs fine and gives the desired outputs. However, when I try to run the code as a function I am greeted by 'Fatal Runtime Error'.
From this I assume that I am setting up the function incorrectly. Am I missing something incredibly obvious?
char array1[26]; = {'\0'};??? Does it compile at all?