Oct 24, 2013 at 10:20am Oct 24, 2013 at 10:20am UTC
Hi, i need help in making the last letter of "bob" Uppercase so it will print out "boB" any ideas, i think im so close but im not sure
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
#include <iostream>
#include <string>
#include <stdio.h>
#include <ctype.h>
using namespace std;
int main(){
{
int i=0;
char Name[] = "bob" ;
char d;
cin >> Name;
while (Name[i])
{
d=Name[i];
if (d = "" ){
i--;
putchar (toupper(d));
}
cout <<"Please Enter your name to Generate a password\n" ;
cout << "Password = " << Name.length() << Name[0] << Name[i]<<endl;
}
return 0;
}
}
Last edited on Oct 24, 2013 at 10:32am Oct 24, 2013 at 10:32am UTC
Oct 24, 2013 at 10:55am Oct 24, 2013 at 10:55am UTC
Thanks that really helped alot, one more thign though, how do i get it so i just prints out the "L" in "michaeL"?
Oct 24, 2013 at 11:00am Oct 24, 2013 at 11:00am UTC
You could use the same technique:
std::cout << c[strlen(c)-1];
I would urge you to use std::string though: http://www.cplusplus.com/reference/string/string/
All the best,
NwN
Oct 24, 2013 at 12:09pm Oct 24, 2013 at 12:09pm UTC
Thanks so much, i got it working now :D and ill look at that link just now thanks again :)