I am using a function prototype to convert month number to month name.
basically you ask the compiler to enter int from 1 to 12 and then convert it.
printMonth ( number ); is the prototype and using switch this is what i did
case 'm':
printf( "What month? Enter a number between 1 and 12: " );
scanf( "%d%c", &number, &tmp );
printMonth( number );
break;
But i just don't know how to call the function . can someone help.
5 14343
I am using a function prototype to convert month number to month name.
basically you ask the compiler to enter int from 1 to 12 and then convert it.
printMonth ( number ); is the prototype and using switch this is what i did
case 'm':
printf( "What month? Enter a number between 1 and 12: " );
scanf( "%d%c", &number, &tmp );
printMonth( number );
break;
But i just don't know how to call the function . can someone help.
I think the best way you need to use is switch case statement:
here the syntax:
switch(variable_expression){
case constant_value;
{
statement 1;
break;
}
case constant_value;
{
statement 2;
break;
}
statement 3;
break;
}
case constant_value;
{
statement 4;
break;
}
(until 12)
default;
satemen 13
break;
}
case 'm':
printf( "What month? Enter a number between 1 and 12: " );
scanf( "%d%c", &number, &tmp );
printMonth( number ); <<<<<<<this is your call
break;
But i just don't know how to call the function . can someone help.
You just called the function.
What am I missing??
I think the best way you need to use is switch case statement:
here the syntax:
switch(variable_expression){
case constant_value;
{
statement 1;
break;
}
case constant_value;
{
statement 2;
break;
}
statement 3;
break;
}
case constant_value;
{
statement 4;
break;
}
(until 12)
default;
satemen 13
break;
}
Thank you so much
that helps me a lot
Hi,
Another simple method. Since month names are not going to change, you can create a static array with month names and just index (after checking for bounds) the array with the number.
Now it becomes a simple array index.
Prasannaa
So something like the following would work... -
static char m_months[13][10] = {"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
-
string month(m_months[n]);
-
Where n is the number entered from the user...
John
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Christopher Benson-Manica |
last post by:
What would be the best way to convert a month number to its corresponding
string? I.e, 3 -> 'March'. Is there a builtin function or must I use a
lookup table or something?
--
Christopher...
|
by: Wayfarer |
last post by:
I've built a report using a aggregate query that is grouped by Month +
Year, Program and Name. When I feed the date ranges as query
parameters, it will very properly print out a report that shows...
|
by: hasanainf |
last post by:
Hi all,
I have two querys
QueryPurchased
ProductID Location TotPcs
Prod1 Loc1 100
Prod2 Loc1 50
Prod3 Loc1 150
Prod3 Loc3 150
|
by: Ken Varn |
last post by:
I want to be able to determine my current line, file, and function in my C#
application. I know that C++ has the __LINE__, __FUNCTION__, and __FILE___
macros for getting this, but I cannot find a...
|
by: Bill |
last post by:
Hello --
I'm parsing the output of the finger command, and was wondering
something...If I'm given a month abbrievation (such as "Jan"), what's
the best way to figure out the month number? I see...
|
by: Aussie Rules |
last post by:
Hi,
How do I extract just the month part of a date. Say for example I wanted to
get the value of 6 (as in sixth month) from todays date.
Regards
|
by: CindySue |
last post by:
Hello--I've got a query that uses DatePart("m",) to select records for a particular month, and then a report based on that query. I'd like to be able to create a field in the report that says what...
|
by: Be Borth |
last post by:
I saw previous solutions to convert a month number (1) to a month name (January). I have a database with 200+ dates. In a query, I use the "Part" function DatePart("m",), to extract the month...
|
by: antonopn |
last post by:
Hello to all!
I'm trying to make a very difficult report. I want to present sales of some products within an year but month-to-month.
lets say that the table would be like this...
...
|
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: 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: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
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: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |