You are not logged in.
I am having some issues with g++ (in geany) failing to build my programs correctly. I used Geany under Ubuntu with no issues with any of my code. To give some context though, I am taking an intro CS class, and the book is about 10 years old. As a result, a lot of my strategies might seem outdated or improper.
Specifically I am finding that the cin.get command runs through:
// Example of Dysfunction
#include<iostream>
using namespace std;
int main()
{
int a;
char test[3];
cout<<"What does 2 + 2 = "<<endl;
cin>>a;
cout<<"Define the string: ";
cin.get(test, 3);
cin.ignore(80, '\n');
return 0;
}
This was executed correctly in Ubuntu. When executed in Arch it does the first "cin>>a", then it runs to the end skipping the "cin.get". Any assistance?
Last edited by nanix (2010-12-04 14:57:51)
Offline
char test[3];
...
cin.get(test, 11);
That seems wrong.... 3 != 11
And this has absolutely nothing to do with geany...
Edit: also, consider using code tags around your code next time.
Offline
Well actually that was just an error when I transferred from geany > forum. And if underscores are really that bothersome and code tags encourage assistance from others, sure I will change my post.
Offline
I think I Duck Duck Go'd the solution! http://www.augustcouncil.com/~tgibson/t … l#problems ("std::cin.getline() can run into problems..." section)
I'm not sure why it worked before.
Offline
I think I Duck Duck Go'd the solution! http://www.augustcouncil.com/~tgibson/t … l#problems ("std::cin.getline() can run into problems..." section)
I'm not sure why it worked before.
Ha, I never considered it was a problem with things left in the buffer with "cin>>a". Thank you for your assistance!
As for it working before, I still can't understand it. I am sitting here right now under ubuntu running the exact same code and it works.
Offline