hi everyone just starting ansi c but i seem to be having problems i have to make a program which checks if the user input is uppercase,lowercase or digit which i have done but for some reason i cant seem to do character counts ive tried one way but it doesnt work and im confused lol but my teacher wnt help as we have already moved on to the next program. so i just want learn what i am doing wrong for future reference.

// portfolio2.cpp : Defines the entry point for the console application.

#include <stdafx.h>
#include <cctype>
#include <cctype>

int _tmain(int argc, _TCHAR* argv[])
  char a; 
  int i;
  int count = 0;
  printf("Please Enter A Character \n");
  scanf( "%c", &a );
   if (isupper (a))
    printf("Number of characters in is %d\n", count);
    printf( "You Entered Uppercase Character \n");
   if (islower (a))
	printf( "You Entered A Lowercase Character \n");
   if( isdigit(a))
    printf( "You entered a Number \n");
  return 0;

any help will be apperciated thanks

9 Years
Discussion Span
Last Post by Superstar288

>so i just want learn what i am doing wrong for future reference.
The first thing would be compiling a C++ program portfolio2.cpp C code doesn't end in .cpp, they end in .c


yea for some reason VS 2008 seems 2 save it as cpp no idea y quite a few of my m8s have the same problem.


It's unclear what you wish to do.

Do you expect the user to enter a single character? If so there is nothing to count (it's ONE character).

So I'll assume you expect the user to enter more than one character and you are trying to count how many of each type of character (upper, lower, digit) the user entered.

In that case you should read the input into a string and loop over the chars in the string. You will need separate counters for each type.


yea sorry about this lol i may have made it unclear what i wanted to do. the user may enter more than 1 character and then the program should say u entered eg uppercase characters etc.
then i want to be able to count how many characters were entered. thanks for the help so far. can i do this without storing it in an array

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.