GTAStunting
General => General Discussion => Computer Talk => Topic started by: Psycho 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:
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:
cout << "Enter second test number: ";
cin >> TestTwo;
The closest I could come up with is:
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.))
-
JayRayfox
-
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.
-
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..
-
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..
int main()
{
return 0;
}
that?
-
yup
-
What happens if you just do:
int userInput = promptForInt("Enter second test number: ");
-
My guess is it won't recognize it as a function, because the supporting function built in reads the line
int promptForInt( const string &promptString )
I'll go try it on the cpp computer, see if it works.
-
What happens if you just do:
int userInput = promptForInt("Enter second test number: ");
Or perhaps:
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.
-
you'd think, but i kept getting errors. plus, i needed to store the response as a variable.
it turned out to be
VARIABLE = int promptForInt( "Enter second test number here: " );
well thanks for the help anyway =) appreciate it.
-
C++ is fucked up. I better like C
-
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...
-
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.