Is there a way I can print a case and then print the previous cases along with the current case selection? For example if I do this
case 3:
printf("*[ 3] 3:59 Radar Love\n");
break;
case 4:
printf("*[ 4] 9:03 Riders On The Storm\n");
break;
and the user selects 3, and then 4 the next time i want it to print out
printf("*[ 3] 3:59 Radar Love\n");
printf("*[ 4] 9:03 Riders On The Storm\n");
is there a way i can do that?
5 1378
Is there a way I can print a case and then print the previous cases along with the current case selection? For example if I do this
case 3:
printf("*[ 3] 3:59 Radar Love\n");
break;
case 4:
printf("*[ 4] 9:03 Riders On The Storm\n");
break;
and the user selects 3, and then 4 the next time i want it to print out
printf("*[ 3] 3:59 Radar Love\n");
printf("*[ 4] 9:03 Riders On The Storm\n");
is there a way i can do that?
You can make it a function and call it recursively, though you'd probably have to change the test for them in each case if you did that....
Or you could just combine the two - have a general condition to get into "case 3_and_4", and then have an if statement in there that, if it was 4, printed 4, and had no else, so it would print 3 no matter what if it went in, and might print 4 as well.
hmmm ok.
im still a little bit confused what does this mean.. i could make it a function but if i just call it... like in a for loop or somethin wont it still only print the one case that's selected?
You can make it a function and call it recursively, though you'd probably have to change the test for them in each case if you did that....
hmmm ok.
im still a little bit confused what does this mean.. i could make it a function but if i just call it... like in a for loop or somethin wont it still only print the one case that's selected?
You can make it a function and call it recursively, though you'd probably have to change the test for them in each case if you did that....
A function is pretty much, a mini-class. It is declared outside your main, but then can be called. It's good for things that you want to use a lot, but only want to code once. -
int main() {
-
-
// .... code and initializations here...
-
celTmp = convertTmp(farTmp);
-
// .... the rest of your code here....
-
}
-
-
float convertTmp(float farTmp) {
-
float celTmp = 0;
-
celTmp = farTmp - 32;
-
celTmp = celTmp / 1.8;
-
return celTmp;
-
}
-
That's the most simple example I can come up with off the top of my head, just so you get an idea of functions. From there, a recursive function is one that calls itself a certain number of times (very useful with searching algorithms).
The more I think about it, the more I'd go with the second option - recursive functions and algorithms can get very confusing very quickly. I'd just make a general case and stick an if statement in there.
ok. I'll work on my if statement for now :) thanks for your help i might be back with more questions :)
ok. I'll work on my if statement for now :) thanks for your help i might be back with more questions :)
Absolutely, or you can PM me if I'm not watching the forum. :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: A.V.C. |
last post by:
Hello,
I found members of this group very helpful for my last queries.
Have one problem with CASE. I can use the column name alias in Order By Clause
but unable to use it in WHERE CLAUSE.
PLS...
|
by: John |
last post by:
Why does the System.IO.FileSystemEventArgs (in FileSystemWatcher object)
return lower case for the file? i.e. e.FullName will return
"c:\testingfilename.xml" instead of the origiiinal...
|
by: Lakshmi Narayanan.R |
last post by:
Hi Experts,
Using keyword "To" in select case giving error.The following code is got
from www.microsrosoft.com itself. What is the wrong with this?.
<%
Dim Number1
Number1 = 7 ' Initialize...
|
by: Martin |
last post by:
In Plauger's THE STANDARD C LIBRARY (1992) there is the source code for
fabs.c (p140).
/* fabs function */
#include "xmath.h"
double (fabs)(double x)
{
switch (_Dtest(&x))
{ /* test for...
|
by: ME |
last post by:
In C# the following code generates a compiler error
("A constant value is expected"):
public void Test(string value)
{
switch (value)
{
case SimpleEnum.One.ToString():
MessageBox.Show("Test...
|
by: alf |
last post by:
Hi,
is it possible that due to OS crash or mysql itself crash or some e.g.
SCSI failure to lose all the data stored in the table (let's say million
of 1KB rows). In other words what is the worst...
|
by: jl2886 |
last post by:
First question:
I have an assigned ID that is based on the month and year and then the numbered case. For example,
If a new policy came in in March of 07 and he was the 67th person who was entered...
|
by: beacon |
last post by:
Hello to everybody,
I have a section on a form that has 10 questions, numbered 1-10, with 3 option buttons per question. Each of the option buttons have the same response (Yes, No, Don't know),...
|
by: aarklon |
last post by:
Hi,
why general integer expressions are not allowed in case labels in
switch statements..????
|
by: Derik |
last post by:
Okay, I THINK this is a PHP question...
I've been mucking with PHP for awhile now, but just recently I've been
poking at some ajax stuff, and I ran into something confusing; my
Queries were...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |