Xcode 8.3 command line C++ -
i have 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 prints out number in reverse order.
when run program in xcode get
program ended exit code: 0
rewrite program print statement in main function so:
int main(int argc, const char * argv[]) { cout<<"hello"; reversestring(123456); return 0; } i same output
program ended exit code: 0
if add \n send of print statement cout<<"hello\n";
i get:
hello
program ended exit code: 0
what going on here? updated xcode 8.3, causing issue? if so, how can fix this?
note: creating project selecting file -> new project -> macos -> command line program
also note: programs i've created in past still run properly.
cout won't print untill send "\n", @ point in code need cout << "\n";
Comments
Post a Comment