Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Basic input output program help

Years of Service
User Offline
Joined: 11th Oct 2012
Posted: 12th Oct 2012 05:20
I am in a computer programming class at school and need some help on a a part of the program.

Here is my code so far. I am having trouble with the part that says Age = ThisYear - YearBorn;
While trying to output the Age to the screen it keeps coming up with the error C2440 that says cannot convert from int to char *

Any ideas?
Brendy boy
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 12th Oct 2012 20:49
you cant subtract two chars! Only numbers (int, float, double)
You have to declare you variables as numbers and then convert the result to char to output it to the screen

Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 12th Oct 2012 21:11
your code is kinda unsafe, however, this is what you might be looking for:

you also probably want to "delete" all your pointers, GDK won't do it for you

Years of Service
User Offline
Joined: 5th Dec 2009
Posted: 4th Nov 2012 19:43 Edited at: 4th Nov 2012 19:44
is saying to the compiler: "Take the pointer address value of 'ThisYear' and subtract from it the pointer address value of 'YearBorn' and put that value into 'Age'"
This is not how pointers are usually done and will not get you what you are looking for.
Create 4 more variables:

These will hold the numeric representations of the character values you entered and held in:

You will need to tell the integer values what they are by adding:

This last bit must be done some time after the input and before the output.

The fastest code is the code never written.

Login to post a reply

Server time is: 2023-09-27 00:27:35
Your offset time is: 2023-09-27 00:27:35