![]() |
| | #1 |
| Student Join Date: Feb 2002 Location: Montreal, Quebec
Posts: 669
| Convert Char to Int Function Code: char convert(int* time,char* outtime)
{
*outtime=(char)*time;
}
Code: e:\programs\projects\opengl tests\graphic opengl stardate\sdopengl\stdate.cpp(11) : error C2664: 'convert' : cannot convert parameter 1 from 'char [100]' to 'int *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
e:\programs\projects\opengl tests\graphic opengl stardate\sdopengl\stdate.cpp(18) : error C2664: 'convert' : cannot convert parameter 1 from 'char [100]' to 'int *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
e:\programs\projects\opengl tests\graphic opengl stardate\sdopengl\stdate.cpp(117) : error C2664: 'convert' : cannot convert parameter 1 from 'int' to 'int *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
mainsource.cpp
|
| drdroid is offline | |
| | #2 |
| Confused Join Date: Sep 2001 Location: Sweden
Posts: 3,122
| First, your function does not return any value though it says it *should* return a char. Second, the error doesn't lie in your function. If you look at the errors, it says "cannot convert parameter 1 from char[100] to int*". Obviously, you're trying to pass a character array to the integer pointer. Have you mixed up the arguments?
__________________ MagosX.com Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime. |
| Magos is offline | |
| | #3 |
| Student Join Date: Feb 2002 Location: Montreal, Quebec
Posts: 669
| .... I'm not passing an array. But, I start by creating a char array which get's passed through the function. I then convert the variable into a number that way I can compare it with other numbers. Then I change it back that way I can put it together with the other characters. So would it work if I got rid of the original char array and just made it a char? |
| drdroid is offline | |
| | #4 |
| Student Join Date: Feb 2002 Location: Montreal, Quebec
Posts: 669
| ... actually no... that's not it... i'll try some other things. |
| drdroid is offline | |
| | #5 |
| Student Join Date: Feb 2002 Location: Montreal, Quebec
Posts: 669
| ... updated code: |
| drdroid is offline | |
| | #6 |
| Student Join Date: Feb 2002 Location: Montreal, Quebec
Posts: 669
| scores: downloads: 2 answers: 0 The downloads are in the lead... but the answers can still catch up!!! |
| drdroid is offline | |
| | #7 |
| Registered User Join Date: Sep 2002
Posts: 1,640
| fetch ya ape! |
| Travis Dane is offline | |
| | #8 |
| Student Join Date: Feb 2002 Location: Montreal, Quebec
Posts: 669
| here source code |
| drdroid is offline | |
| | #9 |
| Crazy Fool Join Date: Jan 2003 Location: Canada
Posts: 2,588
| you dont need to convert the char to an int to do comparisons. example: the following is legit (at least it is with g++) Code:
char blah = 'A';
if(blah > 40)
// do stuff ....
|
| Perspective is offline | |
| | #10 |
| Student Join Date: Feb 2002 Location: Montreal, Quebec
Posts: 669
| ... sorry, i should have said this earlier... td solved the problem on irc. |
| drdroid is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Undefined Reference Compiling Error | AlakaAlaki | C++ Programming | 1 | 06-27-2008 11:45 AM |
| Game Won't Compile | jothesmo | C++ Programming | 2 | 04-01-2006 04:24 PM |
| Incorporating en-passant and Castling into a chess program | mac025 | C Programming | 2 | 03-24-2006 08:36 PM |
| getting a headache | sreetvert83 | C++ Programming | 41 | 09-30-2005 05:20 AM |
| Binary Search Trees Part III | Prelude | A Brief History of Cprogramming.com | 16 | 10-02-2004 03:00 PM |