Tuesday 19 September 2017

How do I use "cin" and "cout" in C++ with TextMate?

I am new to both C++ and TextMate, and I'm running into a problem. When I run my extremely basic "programs" in TextMate using C++, it completely ignores the statement "cout >>" and just either ignores it, or inputs the maximum data value for the basic type I used.


What is going on, and how can I stop it?


The source code is as follows:


#include 
int stonetolb(int);
int main() {
using namespace std;
int stone;
cout << "enter the weight in stone";
cin >> stone;
int pounds = stonetolb(stone);
cout << stone << "stone = ";
cout << pounds <<" pounds.";
return 0;
}

int stonetolb(int sts) {
return 14 * sts;
}

… and the output, regardless of whether or not I even try to put in a number is:



enter the weight in stone0stone = 0 pounds.


No comments:

Post a Comment

Where does Skype save my contact&#39;s avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...