Need Help Filtering just the first letter

This is a discussion on Need Help Filtering just the first letter within the C++ Programming forums, part of the General Programming Boards category; Code: #include <iostream> #include <string> #include <windows.h> #include <stdio.h> #include <time.h> using namespace std; int main() { srand ( time ...

  1. #1
    Registered User Sshakey6791's Avatar
    Join Date
    Nov 2008
    Location
    -
    Posts
    57

    Need Help Filtering just the first letter

    Code:
    #include <iostream>
    #include <string>
    #include <windows.h>
    #include <stdio.h>
    #include <time.h>
    
    using namespace std;
    
    
    int main() {
    
    	srand ( time ( NULL ) );
    
    	unsigned short int NumberOfPassWord; // Number of passwords
    	unsigned short int PassWordLong; // How Long The PassWord 
    	char Alphabet [74] = {'a','b','c','d','e','f','g','h','i','j','k','l',
    
    		'm','n','o','p','q','r','s','t','u','v','w','x','y','z','A',
    		
    		'B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
    		
    		'Q','R','S','T','U','V','W','X','Y','Z','0' };
    
    		char Char [] = { '1','2','3','4',
    		
    		'5','6','7','8','9','!','@','#','$','%','^','&','*','(',')',
    		
    		'?','~' };
    
    	cout << "Enter length of password\n>";
    	cin >> PassWordLong;
    
    	cout << "Enter number of passwords\n>";
    	cin >> NumberOfPassWord;
    
    	for ( unsigned short int counterN = 1; counterN <= NumberOfPassWord; counterN++ ) {
    	
    		for ( unsigned short int counterL = 1; counterL <= PassWordLong; counterL++ )  
    
    
    				cout << Alphabet [ rand() % 74 ];
    
    		for ( ; Alphabet == Char; PassWordLong-- ); 
    
    
    			cout << endl;
    
    		
    
    	}
    
    
    	system("pause");
    
    	return(0);
    
    
    }
    It filters.. but all of the special char and number.. I only want it to filter the first letter if is a special char or number.

    Basically I want the program to filter all passwords that don't start with a letter....
    "Blood you have thirsted for -- now, drink your own!"
    (Dante)

  2. #2
    Registered User Sshakey6791's Avatar
    Join Date
    Nov 2008
    Location
    -
    Posts
    57

    Sorry Here the new Code

    Code:
    #include <iostream>
    #include <string>
    #include <windows.h>
    #include <stdio.h>
    #include <time.h>
    
    using namespace std;
    
    
    int main() {
    
    	srand ( time ( NULL ) );
    
    	unsigned short int NumberOfPassWord; // Number of passwords
    	unsigned short int PassWordLong; // How Long The PassWord 
    	char Alphabet [74] = {'a','b','c','d','e','f','g','h','i','j','k','l',
    
    		'm','n','o','p','q','r','s','t','u','v','w','x','y','z','A',
    		
    		'B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
    		
    		'Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4',
    		
    		'5','6','7','8','9','!','@','#','$','%','^','&','*','(',')',
    		
    		'?','~' };
    
    		char Char [] = { '1','2','3','4',
    		
    		'5','6','7','8','9','!','@','#','$','%','^','&','*','(',')',
    		
    		'?','~' };
    
    	cout << "Enter length of password\n>";
    	cin >> PassWordLong;
    
    	cout << "Enter number of passwords\n>";
    	cin >> NumberOfPassWord;
    
    	for ( unsigned short int counterN = 1; counterN <= NumberOfPassWord; counterN++ ) {
    	
    		for ( unsigned short int counterL = 1; counterL <= PassWordLong; counterL++ )  
    
    
    				cout << Alphabet [ rand() % 74 ];
    
    	for ( ; Alphabet == Char; PassWordLong-- ); 
    
    
    			cout << endl;
    
    		
    
    	}
    
    
    	system("pause");
    
    	return(0);
    
    
    }
    Same problem
    "Blood you have thirsted for -- now, drink your own!"
    (Dante)

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    So do the first one special -- make sure it's not anything weird -- then do the rest in a loop.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. counting letter occurences in a string
    By pjr5043 in forum C++ Programming
    Replies: 35
    Last Post: 05-05-2008, 10:18 PM
  2. Advice requested, Code makes sense to me, not compiler
    By andrew.bolster in forum C Programming
    Replies: 53
    Last Post: 01-06-2008, 01:44 PM
  3. help using strings and mapping
    By trprince in forum C Programming
    Replies: 29
    Last Post: 12-01-2007, 04:01 PM
  4. How To Make Capital Letter To Small Capital Letter??
    By jason07 in forum C++ Programming
    Replies: 3
    Last Post: 10-10-2005, 05:37 PM
  5. Big Letter became small letter
    By cogeek in forum C Programming
    Replies: 27
    Last Post: 12-13-2004, 02:04 PM

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