Author Topic: Need help with DevC++  (Read 1803 times)

0 Members and 1 Guest are viewing this topic.

Offline Psycho

  • Insomniac.
  • Veteran Member
  • Posts: 3078
  • <_<
    • View Profile
Need help with DevC++
« on: September 09, 2008, 10:44:37 AM »
In my class, we have an assignment, involving premade functions, below the main function. We're supposed to make a table using two different methods.

For the first column of entries, we use cin and cout. No problem there.

For the second column of entries, we're supposed to use this function:

Quote
   int promptForInt( const string &promptString )
   {
    // initialize function
    int response;

    // output prompt string
    cout << promptString;

    // input user response
    cin >> response;

    // return user response
    return response;
   }

Now I need the effect of this:
Quote
  cout << "Enter second test number: ";
   cin >> TestTwo;

The closest I could come up with is:

Quote
int promptForInt( const string &"Enter second test number: ");

But I keep getting the error: "expected ',' or '...' before string constant."

If I add a , or ... then I just get more errors. What should I do?

((If I can't figure anything out, I'll just use cin and cout and explain the issue in comments.))
« Last Edit: September 09, 2008, 01:17:36 PM by Psycho »

Offline Labiloute

  • Veteran Member
  • Posts: 2502
    • View Profile
    • YouTube Channel
Need help with DevC++
« Reply #1 on: September 09, 2008, 12:32:00 PM »
JayRayfox

Offline Psycho

  • Insomniac.
  • Veteran Member
  • Posts: 3078
  • <_<
    • View Profile
Need help with DevC++
« Reply #2 on: September 09, 2008, 01:29:08 PM »
my assignment is due in 5 hours so help would be greatly appreciated

@Labiloute, I messaged him and gunner, but they may not come online in time.

Offline godson

  • Veteran Member
  • Posts: 5729
  • zodiac shit!
    • View Profile
Need help with DevC++
« Reply #3 on: September 09, 2008, 01:38:42 PM »
Im doing this in my computer class too..Im doing the beginning part though so Im a noob at it atm..

int main()
return
}
{

someshit like that im doing..
« Last Edit: September 09, 2008, 01:56:09 PM by godson »

Offline Psycho

  • Insomniac.
  • Veteran Member
  • Posts: 3078
  • <_<
    • View Profile
Need help with DevC++
« Reply #4 on: September 09, 2008, 02:09:15 PM »
Quote from: godson
Im doing this in my computer class too..My doing the beginning part though so Im a noob at it atm..

int main()
return
}
{

someshit like that im doing..

Code: [Select]
int main()
{
return 0;
}

that?

Offline godson

  • Veteran Member
  • Posts: 5729
  • zodiac shit!
    • View Profile
Need help with DevC++
« Reply #5 on: September 09, 2008, 02:53:31 PM »
yup

Offline Dannye

  • Veteran Member
  • Posts: 3580
    • View Profile
Need help with DevC++
« Reply #6 on: September 09, 2008, 05:08:15 PM »
What happens if you just do:

int userInput = promptForInt("Enter second test number: ");

Offline Psycho

  • Insomniac.
  • Veteran Member
  • Posts: 3078
  • <_<
    • View Profile
Need help with DevC++
« Reply #7 on: September 09, 2008, 05:29:14 PM »
My guess is it won't recognize it as a function, because the supporting function built in reads the line
Code: [Select]
int promptForInt( const string &promptString )
I'll go try it on the cpp computer, see if it works.

Offline Dannye

  • Veteran Member
  • Posts: 3580
    • View Profile
Need help with DevC++
« Reply #8 on: September 09, 2008, 06:46:23 PM »
Quote from: Dannye
What happens if you just do:

Code: [Select]
int userInput = promptForInt("Enter second test number: ");

Or perhaps:

Code: [Select]
string outputText = "Enter second test number: ";
int userInput = promptForInt(outputText);

One of those options should work, as far as I can tell.

I am not sure what you mean in your last post, perhaps I am misunderstanding your problem.
It looks to me that you need to call the function promptForInt, which has one parameter, a string, and returns an integer - I am pretty sure at least one (or both) of the methods above cover that.  

Offline Psycho

  • Insomniac.
  • Veteran Member
  • Posts: 3078
  • <_<
    • View Profile
Need help with DevC++
« Reply #9 on: September 10, 2008, 01:00:17 AM »
you'd think, but i kept getting errors. plus, i needed to store the response as a variable.

it turned out to be
Code: [Select]
VARIABLE = int promptForInt( "Enter second test number here: " );
well thanks for the help anyway =) appreciate it.

Offline Adonai

  • Posts: 1548
    • View Profile
    • http://
Need help with DevC++
« Reply #10 on: September 10, 2008, 10:13:44 AM »
C++ is fucked up. I better like C

Offline JayFoxRox

  • Posts: 2221
    • View Profile
    • Homepage
Need help with DevC++
« Reply #11 on: September 13, 2008, 04:05:59 PM »
RootCorE: imo, all of the C style languages are fucked up, the only languages I liked so far are those which are pure ASM, Visual Basic 6 (with a few patches this would be the perfect language) and SCM (which is really good, it reminds me of an emulation but its alot easier than writing machinecode)
I'm still waiting for a good design language (like HTML) and script (like PHP) for the internet tho.
Why the fuck, would anyone want it in ascii? multi-os would have it alot easier if anything would be binary...

Offline Adonai

  • Posts: 1548
    • View Profile
    • http://
Need help with DevC++
« Reply #12 on: September 14, 2008, 12:18:48 AM »
I don't like VB at all. SCM is pretty cool, but I don't like spending more than 3 hrs on a SCm script. And I don't think that alternative for HTML will come soon. But it's fun to make Active Controls with MS Silverlight. And yes, binary is waaaaaaaay more better that ASCII.

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal