473,810 Members | 3,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

converting month number to month name

3 New Member
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.
Oct 15 '07 #1
5 14462
simplebelle
5 New Member
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;
}
Oct 15 '07 #2
weaknessforcats
9,208 Recognized Expert Moderator Expert
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??
Oct 15 '07 #3
girl23
3 New Member
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
Oct 15 '07 #4
Prasannaa
21 New Member
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
Oct 18 '07 #5
jwwicks
19 New Member
So something like the following would work...

Expand|Select|Wrap|Line Numbers
  1. static char m_months[13][10] = {"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
  2.     string month(m_months[n]);
  3.  
Where n is the number entered from the user...

John
Oct 19 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
9720
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 Benson-Manica | I *should* know what I'm talking about - if I ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
1
3212
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 a separate page for each program by month with the names of the folks in that program. So far, so good... But what I need to complete the report is a summary page for the entire date range in the same format. I have no &%^# idea how to do that....
7
5385
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
11
21935
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 C# equivalent. Any ideas? -- ----------------------------------- Ken Varn Senior Software Engineer Diebold Inc. varnk@diebold.com
10
7340
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 that there's something called "month_abbr" in the calendar module. However, when I try to do calendar.month_abbr.index("Jan"), I get "_localized_month instance has no attribute 'index'." So it seems that month_abbr isn't a regular list. I'm...
3
34807
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
2
26574
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 month they are for. I can get the month number by using =DatePart("m",) in a text box, but I can't find a way to convert it to the month name. I've experimented with a couple of things I found in the forum, but I'm not talented enough to get them to...
12
23225
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 (number) and all month extracts worked correctly (they returned the correct numerical month). However, when I attempted adding a field in the query to format that extracted month to a month name, it only returned January and December - for all 200+...
3
3084
antonopn
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... customer|specie|quantityJAN|quantityFEB|quantityMAR... But the problem is I need to make all these columns by hand and the query is like this...
0
10379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10393
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7664
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6882
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4334
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3863
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.