Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 03-24-2005, 08:25 PM   #1 (permalink)
hyowza
Registered User
 
Join Date: Mar 2005
Posts: 1
hyowza is on a distinguished road
Converting char to string?

Hi,

i've been trying to figure this out, i've read a few related methods and classes in the API and searched google... i don't know if it's possible but i have a method validkey(char key) if a users inputted key is valid the key must be all upper case characters (ASCII value between 65 and 90). I've written a loop which checks if the key is greater '>' than char(65) and less than char(90) then it is valid.

Now here's the problem...when i pass the variable 'char key' through the valid key method the users enters it it and it works but the problem is that it only accepts 1 character (hmmm not a very good password is it? although i do understand the concept of a char being only one character) but what i want is at least 10 character places in uppercase is it possible to have 10 characters in one char declaration?

What i thought is if i converted the passed string to a char this would allow me to check if the key is valid and the user can enter a password which is a string value and then i'll just be able to check if it's valid through the validkey method (it will accept it once it's converted to a char). Any suggestions?
hyowza is offline   Reply With Quote
Old 03-25-2005, 04:02 AM   #2 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,139
Belisarius is on a distinguished road
A String is really just a wrapper around an array of chars. You can get that array by using toCharArray() on the string. Then you can just run it through your loop and make sure each character is correct.

You could also use the toUpperCase() method to make all the characters uppercase, so your users could type in lower case as well as upper case.
__________________
GitS
Belisarius is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Different string types in C: char pointer, char array, etc. Sleep Standard C, C++ 0 01-23-2005 08:40 PM
Help for another program Androto Standard C, C++ 54 10-15-2004 07:21 AM
From C to Java HighterDK Java 11 07-13-2004 07:15 PM


All times are GMT -8. The time now is 05:46 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting