-
March 6th, 2011, 04:04 AM
#1
How to use #define _CRT_SECURE_NO_DEPRECATE?
Hi,
I am trying to use strcpy. I am getting 'deprecated function warning'. One of the posts on this forum suggests to use
#define _CRT_SECURE_NO_DEPRECATE
before stdafx.h
I have done this but still I am getting lot of warnings:
Code:
1>------ Rebuild All started: Project: testCalendar1, Configuration: Debug Win32 ------
1>Deleting intermediate and output files for project 'testCalendar1', configuration 'Debug|Win32'
1>Compiling...
1>stdafx.cpp
1>Compiling...
1>testCalendar1.cpp
1>d:\vcprog\testcalendar1\testcalendar1\testcalendar1.cpp(38) : warning C4996: 'strcpy' was declared deprecated
1> d:\microsoft visual studio 8\vc\include\string.h(73) : see declaration of 'strcpy'
1> Message: 'This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
1>d:\vcprog\testcalendar1\testcalendar1\testcalendar1.cpp(39) : warning C4996: 'strcpy' was declared deprecated
1> d:\microsoft visual studio 8\vc\include\string.h(73) : see declaration of 'strcpy'
1> Message: 'This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
1>Compiling manifest to resources...
1>Linking...
1>LINK : D:\VCPROG\testCalendar1\Debug\testCalendar1.exe not found or not built by the last incremental link; performing full link
1>Embedding manifest...
1>Build log was saved at "file://d:\VCPROG\testCalendar1\testCalendar1\Debug\BuildLog.htm"
1>testCalendar1 - 0 error(s), 2 warning(s)
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
My code is as follows:
Code:
#define _CRT_SECURE_NO_DEPRECATE
#include "stdafx.h"
#include "string.h"
int days_in_month[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
char *months[]=
{
" ",
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
};
struct Calendar{
char monthName[11];
char DayName[31][3];//worst case
int DayNo[31];
};
Calendar calArr[12]; //12 months
char *DayName[7]={"Mon", "Tue", "Wed", "Thu","Fri", "Sat", "Sun"};
int _tmain(int argc, _TCHAR* argv[])
{
int DayNameIndex;
int month,day;
//_CRT_SECURE_NO_DEPRECATE;
strcpy(calArr[0].DayName[0],"Sat");
strcpy(calArr[0].monthName,"January");
calArr[0].DayNo[0]=1;
DayNameIndex=5;
for ( month = 1; month <= 12; month++ )
{
strcpy_s(calArr[month-1].monthName,months[1]);
//if (month==2) check leap year
for ( day = 1; day <= days_in_month[month]; day++ );
}
Some body plz guide me.
Zulfi.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|