473,395 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to find the ASCII value of the contents of a char variable?

3
Hi,

I am a new programmer, and i want to do the following:

I read a string from the keyboard and i store it in a char variable. The string the user provides through the keyboard can be anything (numbers, letters, etc).

Then, i need to print on the screen the ASCII values of the string (for example, if i write ab through the keyboard, then i want my program to print 6566)
Nov 27 '10 #1

✓ answered by whodgson

It may be better to store what you get from the keyboard in a char array. Then using a loop get each individual char and convert it to ASCII code and place it in a second int array.

3 2739
whodgson
542 512MB
It may be better to store what you get from the keyboard in a char array. Then using a loop get each individual char and convert it to ASCII code and place it in a second int array.
Nov 28 '10 #2
johny10151981
1,059 1GB
Use this code

Expand|Select|Wrap|Line Numbers
  1. char c;
  2. printf("%d",c)
Nov 28 '10 #3
ciao
3
Thanks whodgson, it worked!
Nov 28 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Steve Horsley | last post by:
How can I get the ASCII value of a character, e.g. I have: str = "A B" for index in range(0, len(str)): value = WHAT_GOES_HERE?(str) print value and I hope to get: 65
6
by: Haas | last post by:
Hello folks, I just started a C++ course. An exercise is to give the ASCII value of a character read from keyboard. I place the input from the keyboard in a char-variable. How can i get the...
1
by: sajit | last post by:
hi folks, I am developing a module in asp.net with c# as code behind. The module is used to encrypte the password. The problem is how to find the ascii value of particular character. Any help...
6
by: ssetz | last post by:
Hello, For work, I need to write a password filter. The problem is that my C+ + experience is only some practice in school, 10 years ago. I now develop in C# which is completely different to me....
1
by: Alien | last post by:
Thanks it worked. There was no prbolem. bye
0
by: shisheel | last post by:
Respected experts i am doing a project on the basis of c, For this I need a guidelines. After converting the ASCII value of the charecter that will be converted to its binary...
3
by: krishnaneeraja | last post by:
Hi, im developing one web application using asp.net,c#.net.In that i want to find ASCII value of first character in a string.plz help me. thanks.
1
Unicron
by: Unicron | last post by:
Hey folks. I have searched high and low for the answer to what seems to be a simple problem. Perhaps I don't know how to describe the title properly so if this has been dealt with before, please...
1
by: ritaggalande | last post by:
how to find ascii value of charater using c#.net
5
by: sam177401 | last post by:
I need a program in which a single textbox and a button is there when we enter a text in textbox and press ok button. It should pick the value and post if it is a ascii value. Otherwise it will...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.