I am relatively new to Fortran and am attempting to change each character in a string to all uppercase. I am attempting to iterate through the string and for each character utilize its askii value to change it to uppercase and add the character to a new string. the output is close to what I want it to be but does not include spaces.
Program CaesarCode
implicit none
character(len=2000), parameter::phrase="no spaces"
character(len=len_trim(phrase))::uppercase
integer::i
integer::j= len_trim(phrase)
character::c
do i=1, J
if(ichar(phrase(i:i))<123 .and. ichar(phrase(i:i)) >96) then
uppercase(i:i)= achar(ichar(phrase(i:i))-32)
else if(ichar(phrase(i:i))==95) then
uppercase(i:i)= ' '
end if
end do
print *, uppercase
end Program CaesarCode
I plan on adding more logic to deal with mixed case
example output
NOSPACES