Eastern Members CT, DE, NH, NJ, NY, MA, ME, MD, PA, RI, VT, VA, WV

Paging Purevl

Thread Tools
 
Search this Thread
 
Old Oct 19, 2005 | 06:51 AM
  #1  
lilstephsls1's Avatar
Thread Starter
CT Hotness
iTrader: (5)
 
Joined: Jul 2004
Posts: 2,480
Likes: 1
From: Bristol, CT
Default Paging RhodeIslandRed ;)

Rumor has it that you are good in C++,
is this true?
If so can I ask you a few questions??

Last edited by lilstephsls1; Oct 19, 2005 at 10:58 PM. Reason: retarded
Reply
Old Oct 19, 2005 | 07:56 AM
  #2  
DannoWS6's Avatar
11 Second Club
iTrader: (5)
 
Joined: Apr 2004
Posts: 1,473
Likes: 1
From: Central MA
Default

Post it up Steph.
Reply
Old Oct 19, 2005 | 08:16 AM
  #3  
PurEvl's Avatar
TECH Senior Member
iTrader: (2)
 
Joined: Mar 2002
Posts: 5,469
Likes: 0
From: South of Heaven
Default

oh god Ya i was about 15 years ago..I havent programmed in a long long time, other then scripting in linux and what not
Reply
Old Oct 19, 2005 | 08:26 AM
  #4  
Joe "Preachers Sheets" DIESO's Avatar
Humanitarian
iTrader: (4)
 
Joined: Mar 2002
Posts: 6,466
Likes: 3
From: N/A
Default

You can prob find a bunch of up to date people on a forum, just do a little Google searching.
Reply
Old Oct 19, 2005 | 09:59 AM
  #5  
lilstephsls1's Avatar
Thread Starter
CT Hotness
iTrader: (5)
 
Joined: Jul 2004
Posts: 2,480
Likes: 1
From: Bristol, CT
Default

maybe you know this then danno, its pretty simple but i cant find an answer. I am using a function to ask the user to enter in a number that they can pick between 9 different commands to do (ie add, subtract, modus, multi..etc). So i have to ask the user to enter a number between 0 & 9 depending on what action they want. Now if they enter a 10 or anything else, I am suppose to terminate the whole program. How the hell do i make the program terminate? Do i use 'return 0;' during that function, or do i use another code?
Reply
Old Oct 19, 2005 | 12:11 PM
  #6  
JSTAN's Avatar
Staging Lane
iTrader: (1)
 
Joined: May 2004
Posts: 94
Likes: 0
From: Millis, MA
Default

Originally Posted by lilstephsls1
maybe you know this then danno, its pretty simple but i cant find an answer. I am using a function to ask the user to enter in a number that they can pick between 9 different commands to do (ie add, subtract, modus, multi..etc). So i have to ask the user to enter a number between 0 & 9 depending on what action they want. Now if they enter a 10 or anything else, I am suppose to terminate the whole program. How the hell do i make the program terminate? Do i use 'return 0;' during that function, or do i use another code?
You will have it return 0 during that function......below is an example written in Perl of a script I use....as you see, if you dont enter the correct value, it will fail and promopt you to enter another value...it may also work with C++

sub prompt_phase {
my ( $ans, $subr );

print "\n--------------------------------\n";
print "Please select a phase to execute\n";
print "--------------------------------\n";
print "0. Run steps 1,2,3\n";
print "1. Generate the list of streams for Depot: $::depot\n";
print "2. Examine the contents of each stream\n";
print "3. Scan the stream contents for evil twins\n";
print "Q. Exit\n";
print "\n";
print "Enter Selection: ";
$ans = <STDIN>;
chomp($ans);
exit 0 if ( $ans =~ m/q/i ) || ( $ans =~ m/x/i ) || ( $ans eq "" );

if ( !( ( ( $ans >= 0 ) && ( $ans <= 3 ) ) ) )
{
print "\n\007$ans is not a valid selection\n\n";
return;
}
$subr = "phase_" . $ans;
no strict "refs";
&$subr();
use strict "refs";
}
Reply
Old Oct 19, 2005 | 12:41 PM
  #7  
ARROWSS's Avatar
Coach Purse Queen
 
Joined: Jun 2005
Posts: 60
Likes: 0
From: DelMarVaDC
Default

Yea for perl! /fellow perl coder
Reply
Old Oct 19, 2005 | 12:55 PM
  #8  
8ALTNG's Avatar
TECH Junkie
iTrader: (1)
 
Joined: Aug 2003
Posts: 3,647
Likes: 0
From: Methuen, MA
Default

Im not going to lie. I have absolutly no idea what you guys (and gal) are talking about. I guess thats why I'm a farmer
Reply
LS1 Tech Stories

The Best V8 Stories One Small Block at Time

story-0

Amazing '71 Camaro Restomod Is Modern Muscle Car Under the Skin

 Verdad Gallardo
story-1

6 Common C5 Corvette Failures and What's Involved In Repairing Them

 Pouria Savadkouei
story-2

Retro Modern Bandit Pontiac Trans AM Comes With Burt Reynolds' Autograph

 Verdad Gallardo
story-3

Top 10 Greatest Cadillac V Series Performance Models Ever, Ranked

 Pouria Savadkouei
story-4

Top 10 Most Powerful Chevy Trucks Ever Made!

 
story-5

Hennessey's New Supercharged Silverado ZR2 Has 700 HP

 Verdad Gallardo
story-6

Coachbuilt N2A Anteros Is an LS2-Powered C6 Corvette In Italian Clothes

 Verdad Gallardo
story-7

Awesome K5 Blazer Restomod Comes With C7 Corvette Power

 Verdad Gallardo
story-8

10 Camaros You Should Never Buy

 
story-9

10 LS Engine Myths That Refuse to Die

 Verdad Gallardo
Old Oct 19, 2005 | 12:58 PM
  #9  
Rhode Island Red's Avatar
TECH Fanatic
iTrader: (2)
 
Joined: Mar 2002
Posts: 1,195
Likes: 0
From: I can drive my F-body in Winter!
Cool

1) print out user options
2) read for user input (using an individual char)
3) determine whether a character is a digit (use "isdigit(insert_variable_here)" (include ctype.h) when used it will return 0 (false) if the character is not a digit and 1 (true) if it is....so an ex: "if (isdigit(c)" ... in addtion you need to also check for the letter Q . so a combined statement such as [i]if((isdigit(c)) || ((c == 'q') || (c == 'Q')))if it isn't the input you need,you can clear the scree, and redisplay the options or an error statement or a combination of both.
4) once it is, and bad inputs filtered out, perform a switch statement within the if statement for each option accordingly

Last edited by Rhode Island Red; Oct 19, 2005 at 01:06 PM.
Reply
Old Oct 19, 2005 | 01:05 PM
  #10  
lilstephsls1's Avatar
Thread Starter
CT Hotness
iTrader: (5)
 
Joined: Jul 2004
Posts: 2,480
Likes: 1
From: Bristol, CT
Default

okay that helps. I am also not sure on a void function. I know I have to use this function to print out a menu of options to choose from. It is supposed to display something like this to the user (this is shortened):
'accumulator=0
1) Enter number
2) Add
3) Subtract
4) Mutliply
Please enter a number from 0 to 9:'

How exactly would i use a void function to display this to the screen?
Reply
Old Oct 19, 2005 | 01:10 PM
  #11  
Rhode Island Red's Avatar
TECH Fanatic
iTrader: (2)
 
Joined: Mar 2002
Posts: 1,195
Likes: 0
From: I can drive my F-body in Winter!
Default

void display_the_menu (void)
{
cout << "1) Enter Number \n"; //or printf("1) Enter Number \n");
.
.
.


}

you use a void only when you expect the function to return nothing

in your main procedure, call this function, then read the char, then call the processing function and pass it the character (by value) . and go from there

Last edited by Rhode Island Red; Oct 19, 2005 at 01:17 PM.
Reply
Old Oct 19, 2005 | 01:17 PM
  #12  
lilstephsls1's Avatar
Thread Starter
CT Hotness
iTrader: (5)
 
Joined: Jul 2004
Posts: 2,480
Likes: 1
From: Bristol, CT
Default

i get so confused on this stuff. That makes sense but when you say you don't want it to return anything, does that mean it just goes on to the next function or loop that is next?
Reply
Old Oct 19, 2005 | 01:23 PM
  #13  
Rhode Island Red's Avatar
TECH Fanatic
iTrader: (2)
 
Joined: Mar 2002
Posts: 1,195
Likes: 0
From: I can drive my F-body in Winter!
Default

Originally Posted by lilstephsls1
i get so confused on this stuff. That makes sense but when you say you don't want it to return anything, does that mean it just goes on to the next function or loop that is next?
if the called function does not return anything and the program finishes going through it. It continues down the code and processes the next line of code. Once your finished with the function, that's it your finished with it, even if the function returns something. You could have the function in a while loop, or any repetitve loop, and while the condition is not met, example ((while c != 'q') || (c != 'Q')) run the program.... so in short YES
Reply
Old Oct 19, 2005 | 01:29 PM
  #14  
PurEvl's Avatar
TECH Senior Member
iTrader: (2)
 
Joined: Mar 2002
Posts: 5,469
Likes: 0
From: South of Heaven
Default

steph i would definetly listen to cheesy on this ****...hes been coding a long time
Reply
Old Oct 19, 2005 | 01:29 PM
  #15  
Joe "Preachers Sheets" DIESO's Avatar
Humanitarian
iTrader: (4)
 
Joined: Mar 2002
Posts: 6,466
Likes: 3
From: N/A
Default

Cheesy is the Eastern C++ rep.

We found something your good at!
Reply
Old Oct 19, 2005 | 01:33 PM
  #16  
lilstephsls1's Avatar
Thread Starter
CT Hotness
iTrader: (5)
 
Joined: Jul 2004
Posts: 2,480
Likes: 1
From: Bristol, CT
Default

i am trying hard. I just suck at this ****.
okay i am trying to run the program just but i am coming up with errors regarding my 'display_menu'. Where the hell do I declare that?? . THis is what my program looks like so far:
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main ()
{

//declare and initialize objects
double accumulator(0);
char display_menu;

//ask the user to enter a number that will be the accumulator
cout << "Enter a number ";
cin >> accumulator;

void display_menu()
{
cout << accumulator;
cout << "1) Enter Number \n";
cout << "2) Add \n";
cout << "3) Subtract \n";
cout << "4) Multiply \n";
cout << "5) Divide \n";
cout << "6) Modulus \n";
cout << "7) Raise to power \n";
cout << "8) Square root \n";
cout << "9) Negate \n";
cout << "0) Exit \n";
cout << "Please enter a number from 0 to 9 \n";

return;
}

return 0;

}
Reply
Old Oct 19, 2005 | 01:45 PM
  #17  
Rhode Island Red's Avatar
TECH Fanatic
iTrader: (2)
 
Joined: Mar 2002
Posts: 1,195
Likes: 0
From: I can drive my F-body in Winter!
Default

move the display function outside (and above - traditionally) the main procedure. C++ likes independent procedures. No need to have functions declared within functions with this one.

hint: usually you can trace an obscure error to the earliest line in the program, you understand,if the error is not so obvious. An coding error can create following errors as a result, that are actually not code errors, but the compiler unable to properly interpret the rest of the code after the error (usually syntax errors)

oh , and remove the "\n" and add ": " instead at the readline. People are used to entering at the line commanded, unless the command is quite long
Reply
Old Oct 19, 2005 | 01:59 PM
  #18  
Tracer X's Avatar
LS1TECH Sponsor
 
Joined: Dec 2001
Posts: 3,310
Likes: 0
From: I'm glad one of us finds this amusing...
Default

I told you guys Cheesy is a smart motherphuker! I just didn't know at what.
Reply
Old Oct 19, 2005 | 02:42 PM
  #19  
lilstephsls1's Avatar
Thread Starter
CT Hotness
iTrader: (5)
 
Joined: Jul 2004
Posts: 2,480
Likes: 1
From: Bristol, CT
Default

awesome!! i just went to get a little help from the teacher and he talked me through some of it. I feel so helpless when it comes to this ****.
Reply
Old Oct 19, 2005 | 04:37 PM
  #20  
lilstephsls1's Avatar
Thread Starter
CT Hotness
iTrader: (5)
 
Joined: Jul 2004
Posts: 2,480
Likes: 1
From: Bristol, CT
Default

thank you so much cheese. i got it to work finally. For some reason i thought i could put the void and double functions inside the main function, which caused me to have about a million errors and freak out. After all that shananagans, the rest was pretty simple. I had to use a switch statement to give me the calculations and whatnot. That stuff seems pretty easy. Thanks for your help again!
Reply



All times are GMT -5. The time now is 03:29 PM.

story-0
Amazing '71 Camaro Restomod Is Modern Muscle Car Under the Skin

Slideshow: This heavily modified 1971 Camaro mixes classic muscle car styling with a fifth-generation Camaro interior and modern LS3 power.

By Verdad Gallardo | 2026-05-12 18:06:42


VIEW MORE
story-1
6 Common C5 Corvette Failures and What's Involved In Repairing Them

Slideshow: From wobbling harmonic balancers to failed EBCMs, these are the issues that define long-term C5 ownership and what repairs typically involve.

By Pouria Savadkouei | 2026-05-07 18:44:57


VIEW MORE
story-2
Retro Modern Bandit Pontiac Trans AM Comes With Burt Reynolds' Autograph

Slideshow: A modern Camaro transformed into a retro icon, this limited-run "Bandit" build blends nostalgia with brute force in a way few revivals manage.

By Verdad Gallardo | 2026-04-21 13:57:02


VIEW MORE
story-3
Top 10 Greatest Cadillac V Series Performance Models Ever, Ranked

Slideshow: Cadillac didn't just crash the high-performance luxury vehicle party, it showed up loud, supercharged, and occasionally a little unhinged...

By Pouria Savadkouei | 2026-04-16 10:05:15


VIEW MORE
story-4
Top 10 Most Powerful Chevy Trucks Ever Made!

Slideshow: Top ten most powerful Chevy trucks ever made

By | 2026-03-25 09:22:26


VIEW MORE
story-5
Hennessey's New Supercharged Silverado ZR2 Has 700 HP

Slideshow: Hennessey has turned the Silverado ZR2 into a 700-hp off-road monster with supercharged V8 power and a limited production run.

By Verdad Gallardo | 2026-03-24 18:57:52


VIEW MORE
story-6
Coachbuilt N2A Anteros Is an LS2-Powered C6 Corvette In Italian Clothes

Slideshow: A one-off sports car that looks like a vintage Italian exotic-but hides a C6 Corvette underneath-just sold for the price of a new mid-engine Corvette.

By Verdad Gallardo | 2026-03-23 18:53:41


VIEW MORE
story-7
Awesome K5 Blazer Restomod Comes With C7 Corvette Power

Slideshow: A heavily reworked 1972 K5 Blazer swaps its off-road roots for a low-slung street-focused build with modern V8 power.

By Verdad Gallardo | 2026-03-09 18:08:45


VIEW MORE
story-8
10 Camaros You Should Never Buy

Slideshow: There are thousands of used Camaros on the market but we think you should avoid these 10

By | 2026-02-17 17:09:30


VIEW MORE
story-9
10 LS Engine Myths That Refuse to Die

Slideshows: Which one of these myths do you believe?

By Verdad Gallardo | 2026-01-28 18:10:11


VIEW MORE