I have written this little piece in C++ and if I open the program it should sum up the input then the "Press to finish" should be printed, and after it is printed the application should close after the user enters 'Enter'. The problem is it closes itself already after the numbers added are added.
#include <stdlib.h>
#include <stdio.h>
int multi(int a, int b){
return a * b;
}
int main(){
printf("Programm started \n");
int number1;
int number2;
int sum;
printf("Type two numbers: \n");
scanf("%d %d", &number1, &number2);
sum = multi(number1,number2);
printf("The solution is: %d \n", sum);
printf("Press <Return> to finish \n");
char c = getchar();
if(c=='\n'){
return 0;
}
}