0

I got this code.. now the challenging part is my prof asked me to make a program which asks the user to input an uppercased word.

The problem is, she wants the program to automatically transform each inputted letter in uppercase even if the user's keyboard is not in capslock mode.. so i don't know what's really wrong with my program... anyone?? help?? i really need it.. thanks..

#include<stdio.h> #include<ctype.h> #include<string.h> typedef char String[100]; main() { char Resp; int l, x = 0, asc = 13; String s, word1; clrscr(); do { printf("\n1st uppercased word: "); do { s[0] = getch(); word1[x++] = s[0]; strupr(s); strcat(s, "\0"); puts(s); } while (s[0] != (char) asc); strcat(word1, "\0"); printf("\n\n1st word in lowercase: "); for (l = 0; l < strlen(word1); l++) putchar(tolower(word1[l])); printf("\nDo you want to continue?[Y/N]: "); Resp = getche(); } while (toupper(Resp) == 'Y'); getch(); return 0; } 
4
  • You should tell your professor what he meant by that statement because it doesn't make any sense to say something like that. Plus your code is really hard to read with it indentation. Commented Jul 28, 2010 at 1:22
  • @thyrgle: It made sense to me --- check my answer. Commented Jul 28, 2010 at 1:24
  • @Jacob: Ohh...Ok... Still, I interpreted as you need to make a program that converts everything to uppercase. Now I want you to make sure all this works with out the user pressing capslock. Commented Jul 28, 2010 at 1:28
  • If the answer's OK, normal SO practice is to accept it. Commented Jul 30, 2010 at 9:22

1 Answer 1

11
  1. Get a letter from the user with getch()
  2. Convert it to uppercase with toupper()
  3. Display it with putch()
  4. Go to 1

You may add a break point --- check if the character is the return key and exit.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.