How can i convert - Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Webmaster Tech > Programming > Other Programming - Perl, C++, Java, ASP, .NET Development

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-02-2010, 06:50 AM   #1 (permalink)
Junior Member
 
Join Date: Feb 2010
Posts: 36
Question How can i convert

How can i convert the integer into it's equivalent ASCII Value?In C++
luky is offline   Reply With Quote
Sponsored Links
Old 03-05-2010, 07:09 AM   #2 (permalink)
Junior Member
 
Join Date: Feb 2009
Posts: 69
Default Re: How can i convert

There should be some one who is expert in C++ could help you in this way.
home123 is offline   Reply With Quote
Old 03-08-2010, 06:38 AM   #3 (permalink)
Junior Member
 
Join Date: Feb 2010
Posts: 36
Default Re: How can i convert

ok so i want feedback of some one who is expert in C++
luky is offline   Reply With Quote
Old 03-18-2010, 09:59 AM   #4 (permalink)
Junior Member
 
Join Date: Feb 2010
Posts: 25
Thumbs up Re: How can i convert

Hello,

In this program, I open a text file with a username and password on two lines which are in ASCII value and turn them back into characters so they become words again. In my case, my numbers are (98 108 117 101 122 111 114) and I want to turn it back into the word (bluezor) (and leave out the white-spaces along the way?). I'm having trouble changing it back to letters.

logOnCharacter.c

void logOnCharacter()
{
std::string username = "";
std::string password = "";

//initialises the arrays to store username and password and sets every slot NULL
char usernameArray_char[100];
char passwordArray_char[100];
int usernameArray_int[100];
int passwordArray_int[100];
for (int i = 0; i < 100; i++)
{
usernameArray_char[i] = ' ';
passwordArray_char[i] = ' ';
usernameArray_int[i] = 0;
passwordArray_int[i] = 0;
}

ClearScreen();

std::ifstream charFile ("gameData.txt");
if (charFile.is_open())
{
getline(charFile, username); //gets first line and enters it as username
getline(charFile, password); //gets second line and enters it as password

for (int i = 0; i < username.length(); i++) //** I think I need help here **
{
usernameArray_char[i] = username[i];
std::cout << usernameArray_char[i];
}

charFile.close();
}
else
{
std::cout << "Unable to locate or open gameData.txt." << std::endl;
std::cout << "Please create a new game file by running the program again" << std::endl;
}
}

This outputs the ASCII values (98 108 117 101 122 111 114) correctly, so this is where it starts to get wrong I believe?


for (int i = 0; i < username.length(); i++) //** I think I need help here **
{
usernameArray_char[i] = username[i];
std::cout << char(usernameArray_char[i]);
}

When I try to do this to change the value into a character it still stays as an ASCII value so I don't know why.
jhoney142 is offline   Reply With Quote
Old 03-24-2010, 10:32 AM   #5 (permalink)
Junior Member
 
Join Date: Feb 2010
Posts: 36
Default Re: How can i convert

Hmmm That's impressive
Thanks a lot my dear i got the right idea now
luky is offline   Reply With Quote
Old 06-08-2010, 06:03 AM   #6 (permalink)
Member
 
Join Date: Feb 2010
Posts: 295
Default Re: How can i convert

ok so i want feedback of some one who is expert in C++
kinah is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 04:51 PM.


Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Webmaster Forums
Web Hosting | Chicago Web Hosting | Web Hosting