OUTPUT:
Please enter your full name and birthdate: First Last B-day
Example: JohnDoe2201989...No spaces please.
HARRY
================
hARRY
haRRY
harRY
harrY
harry
___________________________________________________
Here is the code.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
string Name;
int i, c, b, a;
char buf[5096];
char d, e, f;
cout << "Please enter your full name and birthdate: First Last B-day" << endl;
cout << "Example: JohnDoe2201989...No spaces please." << endl;
cin >> Name;
cout << "================" << endl;
for(i = 0; i < Name.length(); i++)
{
Name[i] = tolower(Name[i]);
cout << Name << endl;
}//close name.length
}//close main
I realise I have way more variables than I need, but I always start with more than I need, and when I don't use them I just delete them. and I may end up using fstream later on as a modification to the program...
Basically what it's supposed to do is take in a user-defined string, and than take that string and give each character a numerical value from 1-26, depending on the letter it is, using [ ( c - 'a' ) + 1 ] <-----gives an numeric value from 1-26 of the alphabet....
I'm supposed to use recursion, but I don't really comprehend that yet, I have to read up on it, but for now, I just want to get sprintf down.
This post has been edited by IngeniousHax: 21 April 2009 - 11:27 PM

New Topic/Question
Reply



MultiQuote





|