-3
1 - I have this code (Gave An Abridged, Type -1, And Then 'n' To Exit The Loop And Make The Mistake):
#include <iostream>
#include <cstdlib>
#include <cstdio>
#undef max
using namespace std;
int* cont = new int(0);
//-----------------------------------------// MAIN // -----------------------------------//
void main(){
char* n = new char('s');
while (*n == 's' || *n == 'S'){
int* dinheiro = new int(500);
while (*dinheiro >= 1){
printf("Quanto Deseja Apostar ? ");
scanf("%d%*c", &*dinheiro);
printf("\nTentar Novamente (s-n) ? ");
cin >> n;
cin.ignore(numeric_limits<int>::max(), '\n');
system("cls");
}
delete dinheiro;
}
delete n;
}
And in that part:
printf("Tentar Novamente (s-n) ? ");
cin >> *n;
cin.ignore(numeric_limits<int>::max(), '\n');
system("cls");
If user does not type’s' to get back in the loop it gives this error:
Obs.: Apart from the delete
the program works correctly.
No need to worry about every byte. I find it unlikely that swapping int for void will save anything. Returning an int is one of the simplest things a program usually does, because the value is returned inside a processor logger.
– marcus
You’re distressed by the wrong things ;-) But if you still want to fret about it, I suggest you do the Disassembly of the generated code (with and without optimizations, to compare), and compare the results. Also run a benchmarks to measure time and memory usage. If you notice any difference I swallow my diploma (<- this is figure of speech, haha)
– marcus