Printing name in reverse order and in caps

This is a discussion on Printing name in reverse order and in caps within the C++ Programming forums, part of the General Programming Boards category; Hi, I'm trying to print my name in reverse and in capital letters. I got this far and I am ...

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    71

    Printing name in reverse order and in caps

    Hi,

    I'm trying to print my name in reverse and in capital letters. I got this far and I am almost certain this is correct, but when I compile I get a bunch of numbers and not my name.

    Can anyone give me hand please?

    Code:
    #pragma hdrstop
    #include<iostream>
    #include<conio>
    using namespace std;
    using std::toupper;
    
    //---------------------------------------------------------------------------
    
    #include<string.h>
    #pragma argsused
    
    int main()
    {
    char name[] = {"Jason"};
    int character;
    character = strlen(name);
    
    for (int i = strlen(name); i >= 0; i--)
    {
       character = name[i];
       character = toupper(character);
       cout << character;
    }
    
       getch();
       return 0;
    
    }

  2. #2
    Registered User
    Join Date
    Oct 2002
    Posts
    291
    Code:
    char name[] = {"Jason"};
    char character;
    
    for (int i = strlen(name) - 1; i >= 0; i--)
    {
       character = name[i];
       character = toupper(character);
       cout << character;
    }

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21