View Single Post
Old 04-20-2005, 03:00 AM   #2 (permalink)
Moskie
Pure Chewing Satisfaction
 
Moskie's Avatar
 
Location: can i use bbcode [i]here[/i]?
make sure to use the "code" block when you can:

Code:
#include <stdio.h>

main()
{
  int i;
  char z[20];
  gets(z);
  for(i=0; i<20; i=i+1)
  {
    if (z[i]>='A' && z[i]<='Z')
    {
      z[i]=z[i]+ 'a'-'A';
    }
  }
  
  printf("%s\n",z);
  getchar(); 
}
You're probably going to have to go through your string of characters twice... one loop to make sure it does appear to have been typed with caps lock on, and then another loop to actually make the changes (if your first loop says you should). So in your first loop, check if index 0 is lower case, and all the others are upper. If either of those statemets is false through the loop, set a boolean value to false. Then after the loop, check that boolean to see if you should go through with the change.

Hopefully that'll get you in the right direction.
__________________
Greetings and salutations.

Last edited by Moskie; 04-20-2005 at 03:05 AM..
Moskie is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76