first off i'm new to the board, would like to say hello to all, look forward to working with everyone.

that being said here's my problem, I have a rather simple piece of code with a for loop, and i need to create another loop that makes the majority of the code i have written loop, including what's in the for loop. the code is as follows

the 2nd loop should start after the first printf statement (only request the input once) and should encompass the rest of the code... when i attempt to write it i somehow cause and infinite loop with really skewed checksum values. if someone could point me in the right direction i'd really appreciate it.

i'm also having trouble getting the loop to end on the input of only a '.' , I think that's probably related to my faulty loop.

thanks for any help you can give!

Code:
// this program will read in a string of char's ending in a period, and then calculate
// the checksum, and print it out in both the char and int formats

  #inclde<stdio.h> 
 
  #define START_CHAR ' ' 
  #define END_CHAR '.'
 
  int check_sum(int sum) //function prototype
 
  int main(void) {

  int char_code,sum,checksum,x; //declared variables
  char letter; //declared character
 
  /*ask for input*/
  printf("Enter a message ending in a period; or a period only to quit.\n\n");

     /*initialize sum at 0, until char_code = '.' , add it to the sum*/ 
     for(sum = 0; char_code != (int)END_CHAR; sum += char_code) {
          scanf(" %c", &letter);       //read in string ending in period
          char_code = (int)letter;    //swap character to integer
     }
 
  checksum = check_sum(sum);  // call function
 
printf("Checksum: %c %d\n", (char)checksum, (int)checksum);   //print checksum
 
return(0);
 
}