Solved

output a letter as a number

Posted on 1998-05-20
22
162 Views
Last Modified: 2010-04-15
I want to make a program that outputs fx. ¤ when i enter a b.
How do i do this?
i use djgpp
0
Comment
Question by:hh
  • 7
  • 7
  • 5
  • +1
22 Comments
 
LVL 11

Accepted Solution

by:
alexo earned 50 total points
ID: 1250838
It is hard to understand your intention.

Do you want to print the ASCII value of a character?
Just use it as an integer:
    char ch = 'a';
    int i = ch;
    printf("Char: %c = ASCII: %d\n", ch, i);

Do you want to convert a numeric string into a number?
Use the atoi() function:
    char* str = "4267";
    int i = atoi(str);

Do you want to convert a range of characters to a range of numbers?
Subtract the value of the 'a' character and add the value of the '0' (zero) character:
    char ch = 'a';
    int i = ch - 'a' + '0';

If it's something else please state so or give an example.
0
 
LVL 11

Expert Comment

by:alexo
ID: 1250839
Oh, one more thing.  To use atoi() you have to #include <stdlib.h>
0
 

Author Comment

by:hh
ID: 1250840
i want to assign fx * to a b and print afterwards
0
 
LVL 11

Expert Comment

by:alexo
ID: 1250841
>>  i want to assign fx * to a b and print afterwards

Huh???  Can you explain that statement?  What is fx * ?  What is a b ?
0
 

Expert Comment

by:rsjetty
ID: 1250842
simply use the function convert_fxstar_to_ab_andPrint();
note you need to include the header "fxab_utilities.h" !!!
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1250843
No need for that .. just say
  ab = fx*;
  print = fx*;
this avoids the need for the "fxab_utilities.h".  This does require the fx* language extensions to avoid syntax errors :-)
0
 
LVL 11

Expert Comment

by:alexo
ID: 1250844
And the autograder hits again!

I'll never understand those users...
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1250845
I couldn't even understand the question !!!
0
 

Expert Comment

by:rsjetty
ID: 1250846
So it's done finally ...eh.
wonder why the autograder didn't appreciate fxab_utilities ...???

0
 

Author Comment

by:hh
ID: 1250847
how the f**** du i grade this answer??????????????????????????????????????????.
There used to be room for that?????????????
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1250848
Well .. what you do is select a grade BEFORE EE autogrades it.

If you leave a question too long EE autogrades and closes on the assumption that you don't care anymore (perhaps you've forgotten all about it, or got run over by a bug or ...)

You last comment was about 3 weeks ago.  That is too long for EE - see the FAQ and help for more info about this.

And what on earth did your question mean anyway???

0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:hh
ID: 1250849
I have worked it out, all I need now is to grade the answer, ok?
0
 
LVL 11

Expert Comment

by:alexo
ID: 1250850
The EE software automatically graded it since there was no traffic for three weeks.  The autograde is "C".  If you have any problem with that, complain in the "Experts Exchange" area (http://www.experts-exchange.com/topics/experts-exchange) but I suggest you read http://www.experts-exchange.com/info/faq.htm before you do.
0
 

Author Comment

by:hh
ID: 1250851
ok, sorry but i had forgot about my question and dident grade it, hope you can forgive me?
0
 

Expert Comment

by:rsjetty
ID: 1250852
hey hh,
alexo is right.
Leave the EE-AG alone ...

0
 

Author Comment

by:hh
ID: 1250853
i will, thx all
0
 
LVL 11

Expert Comment

by:alexo
ID: 1250854
Just out of curiosity, how would you grade the answer?
0
 

Author Comment

by:hh
ID: 1250855
I think it would have been c/b, the autograde sounds fair
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1250856
BUT WHAT DID THE QUESTION MEAN ???

Does _anyone_ understand what "i want to assign fx * to a b and print afterwards" actually means?

0
 
LVL 11

Expert Comment

by:alexo
ID: 1250857
42
0
 

Author Comment

by:hh
ID: 1250858
STOP this thread, i have figured it out, and I dont want any more mail from this question:
agree??

once again thx all

later
HH
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1250859
OK .. it sounds like this question will remain one of the great unsolved mysteries.

If you could share your solution with the rest of us, hh, it would be appreciated.  These questions get added to the PAQ (previously asked quesrtions) database, and other customers are free (after paying points) to look it up.  If they do so, then they could be a little annoyed in that the question appears to be, to put it bluntly, gibberish.

Can you PLEASE restate (preferably in a way that makes sense to someone else) WHAT it was you wanted to know and what the solution was that you found.  Just for the record?

0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now