This commit is contained in:
ZennDev1337 2024-01-22 10:26:02 +01:00
parent 9bf81f1adc
commit b21c717fdd
4 changed files with 24 additions and 12 deletions

View file

@ -9,7 +9,7 @@
"-ggdb",
"-std=c++20",
"-pedantic-errors",
"${file}",
"${fileDirname}/**.cpp",
"-o",
"${fileDirname}\\build\\${fileBasenameNoExtension}.exe"
],
@ -30,7 +30,7 @@
"-DNDEBUG",
"-std=c++20",
"-pedantic-errors",
"${file}",
"${fileDirname}/**.cpp",
"-o",
"${fileDirname}\\build\\${fileBasenameNoExtension}.exe"
],

14
io.cpp Normal file
View file

@ -0,0 +1,14 @@
#include "io.h"
#include <iostream>
int readNumber()
{
std::cout << "Enter a number to add: ";
int x{};
std::cin >> x;
return x;
}
void writeAnswer(int x)
{
std::cout << "The answer is: " << x << "\n";
}

4
io.h Normal file
View file

@ -0,0 +1,4 @@
#pragma once
int readNumber();
void writeAnswer(int x);

View file

@ -1,17 +1,11 @@
#include <iostream> // for std::cout
// Definition of user-defined function doPrint()
void doPrint() // doPrint() is the called function in this example
{
std::cout << "In doPrint()\n";
}
#include "io.h"
// Definition of function main()
int main()
{
std::cout << "Starting main()\n";
doPrint(); // Interrupt main() by making a function call to doPrint(). main() is the caller.
std::cout << "Ending main()\n"; // this statement is executed after doPrint() ends
int a{readNumber()};
int b{readNumber()};
writeAnswer(a + b);
return 0;
}