how to directly convert char to numbers?

C++ convert char * to char?

  • I've been trying to applying conditions so a users input so they should input a number followed by a letter i then extract and save both the number and letter section these have to by saved as char * types to use the cin.getline() i then need to convert the letter to a char type so i can use statements like (if letter==t then ....; but i cant use these operators with a char * nor can i convert the char * to a char. any ideas?

  • Answer:

    You can de-reference the pointer! Try using it like this: if ( letter == *cptr) // where cptr is the char pointer { }

David at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

google "working with pointers C++" The char* just means the variable holds a pointer to a place in memory reserved for a value of size char. That char value can be accessed and changed. I think it's &varName, but I don't use C++ really so I always forget, that google search will give the info you need though.

coachabower

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.