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
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:
- How to Convert Code from VB to C++?Best solution by Stack Overflow
- How to Convert a C++ Structure into C# Structure?Best solution by Stack Overflow
- How to convert a char array into an int in C++?Best solution by Stack Overflow
- How to convert from string to char in C++?Best solution by Stack Overflow
- Converting char array to double in C?Best solution by stackoverflow.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.