357mag 3 Posted December 23, 2024 Here is one of my projects which was written in an earlier version of C++ Builder. You will notice that I'm using #include<conio.h> plus I'm using getch(); // This program demonstrates writing a simple function to cube a number #include <iostream> #include <conio.h> using namespace std; int cube(int y); // function prototype int main() { int x; cout << "Enter an integer value: "; cin >> x; int answer = cube(x); // call the cube function and pass x as an argument and assign result to the variable answer cout << "That number cubed is " << answer << endl; // print the result getch(); return 0; } int cube(int y) // function definition { return y * y * y; } Share this post Link to post
Remy Lebeau 1542 Posted December 24, 2024 (edited) And, the point of this post is... what, exactly? I don't see a question or problem stated. However, why were you ever mixing C's <conio.h> with C++'s <iostream> in the first place? Get rid of <conio.h>, you don't need it. Use std::cin.get() instead of getch(). Edited December 24, 2024 by Remy Lebeau Share this post Link to post
357mag 3 Posted December 25, 2024 Someone asked to see the code. So I post the code. Share this post Link to post
David Heffernan 2404 Posted December 25, 2024 1 hour ago, 357mag said: Someone asked to see the code. So I post the code. Imagine we are starting at the beginning of this post. What are we to make of what is in this page alone? Share this post Link to post
Remy Lebeau 1542 Posted December 25, 2024 (edited) 2 hours ago, 357mag said: Someone asked to see the code. So I post the code. Then you should have posted the code as a reply to that earlier discussion. Instead, you posted it as a new discussion with no context. At least add a link to the original discussion. Edited December 25, 2024 by Remy Lebeau Share this post Link to post