I have a simple program in Xcode 8.3
#include <iostream>
using namespace std;
void reverseString(int);
int main(int argc, const char * argv[]) {
reverseString(123456);
return 0;
}
void reverseString(int numString){
if(numString < 10){
cout<<numString;
}else{
cout<<numString % 10;
reverseString(numString/10);
}
}
The code just prints out a number in its reverse order.
When I run the program in Xcode I get
Program ended with exit code: 0
Rewrite the program with a print statement in the main function like so:
int main(int argc, const char * argv[]) {
cout<<"Hello";
reverseString(123456);
return 0;
}
I get the same output
Program ended with exit code: 0
If I add \n to the send of the print statement cout<<"Hello\n";
I get:
Hello
Program ended with exit code: 0
What is going on here? I recently updated to Xcode 8.3, could that be causing the issue? If so, how can I fix this?
Note: I am creating my project by selecting file -> new project -> MacOS -> Command Line Program
Also note: Programs I've created in the past still run properly.