You are not logged in.

#1 2010-12-04 13:26:36

nanix
Member
Registered: 2010-11-07
Posts: 11

[Solved] g++ (in geany) building errors under Arch

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

#2 2010-12-04 13:38:36

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,365
Website

Re: [Solved] g++ (in geany) building errors under Arch

nanix wrote:

    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

#3 2010-12-04 14:13:12

nanix
Member
Registered: 2010-11-07
Posts: 11

Re: [Solved] g++ (in geany) building errors under Arch

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

#4 2010-12-04 14:35:59

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: [Solved] g++ (in geany) building errors under Arch

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. hmm

Offline

#5 2010-12-04 14:57:26

nanix
Member
Registered: 2010-11-07
Posts: 11

Re: [Solved] g++ (in geany) building errors under Arch

drcouzelis wrote:

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. hmm

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

Board footer

Powered by FluxBB