當(dāng)柳上原的風(fēng)吹向天際的時(shí)候...

          真正的快樂(lè)來(lái)源于創(chuàng)造

            BlogJava :: 首頁(yè) :: 聯(lián)系 :: 聚合  :: 管理
            368 Posts :: 1 Stories :: 201 Comments :: 0 Trackbacks

          #

              FROM:

          http://blog.csdn.net/pangdingshan/article/details/7198760



             系統(tǒng)環(huán)境:windows 7 旗艦版

                軟件版本:IBM DB2數(shù)據(jù)庫(kù)(DB2_ESE_97_Win_x86)

                準(zhǔn)備工作:關(guān)閉防火墻及殺軟等安全防護(hù)軟件

               本文是事后整理的,可以在循序上有些亂,有些步奏也是省略的,省略的都是選擇默認(rèn)選項(xiàng)

          1.   運(yùn)行安裝目錄下的  setup.exe 程序,點(diǎn)擊“下一步”

          2.    選擇“我接受許可證協(xié)議中的全部條款”,點(diǎn)擊“下一步”

          3.  根據(jù)自己需求選擇安裝方式,我選擇“典型安裝”,點(diǎn)擊“下一步”

          4.   選擇“在此計(jì)算機(jī)上安裝DB2Enterprise Server Edition ” ,點(diǎn)擊“下一步”

          5.    更改安裝路徑,點(diǎn)擊“下一步”

          6.    默認(rèn)選項(xiàng),點(diǎn)擊“下一步”

           

          7.    設(shè)置密碼,點(diǎn)擊“下一步”

           

          8. 不勾選“設(shè)置DB2服務(wù)器以發(fā)送通知”,點(diǎn)擊“下一步”

          9.    勾選“啟動(dòng)操作系統(tǒng)安全性”,點(diǎn)擊“下一步”

          10.   勾選“準(zhǔn)備DB2工具目錄”,點(diǎn)擊“下一步”

           

          11.  點(diǎn)擊“下一步”,進(jìn)行安裝

            安裝成功后會(huì)有提示



          我安裝的時(shí)候出現(xiàn)以下問(wèn)題:
          posted @ 2013-07-14 00:11 何楊 閱讀(344) | 評(píng)論 (0)編輯 收藏

          http://www.cnblogs.com/mingmingruyuedlut/archive/2011/11/04/2235630.html


          1:

          Internet Information Services 7.5

          Error Summary

          HTTP Error 500.19 - Internal Server Error

          The requested page cannot be accessed because the related configuration data for the page is invalid.

          Detailed Error Information
          Module IIS Web Core
          Notification Unknown
          Handler Not yet determined
          Error Code 0x80070005
          Config Error Cannot read configuration file due to insufficient permissions
          Config File \\?\C:\Users\EricSun\Documents\Visual Studio 2010\WebSites\SSOAuthWebSite1\web.config
          Requested URL http://10.2.5.153:10001/
          Physical Path  
          Logon Method Not yet determined
          Logon User Not yet determined
          Config Source
           -1:     0:  
          Links and More InformationThis error occurs when there is a problem reading the configuration file for the Web server or Web application. In some cases, the event logs may contain more information about what caused this error.

          View more information »

           

          Cause:1) 沒(méi)有向iis中注冊(cè).net framework(引起的原因之一:先安裝了.net framework,后安裝的iis)

              2) 沒(méi)有對(duì)IIS中所配置的site有足夠的操作權(quán)限(Modify權(quán)限)

          Solution:

              1) 到C:\Windows\Microsoft.NET\Framework64\v2.0.50727下,

                用命令向iis中重新注冊(cè)一下.net framework:aspnet_regiis -i

              2) IIS Manager --> Sites --> 相應(yīng)的site --> 點(diǎn)擊右鍵 --> Edit Permissions --> Security --> Group or user names --> Edit --> Add --> 添加賦予Full Control權(quán)限(實(shí)質(zhì)上帶有Modify的權(quán)限就可以)的Everyone用戶

           


          2:

          Server Error in '/' Application.


          Configuration Error

          Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

          Parser Error Message: Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive.

          Source Error:

          Line 9:  	</connectionStrings> Line 10: 	<system.web> Line 11: 		<compilation debug="true" targetFramework="4.0"/> Line 12: 		<authentication mode="Forms"> Line 13: 			<forms loginUrl="~/Account/Login.aspx" timeout="2880"/>


          Source File: C:\Users\EricSun\Documents\Visual Studio 2010\WebSites\SSOAuthWebSite1\web.config    Line: 11


          Version Information: Microsoft .NET Framework Version:2.0.50727.4963; ASP.NET Version:2.0.50727.4955

           

          Cause:當(dāng)前程序所運(yùn)行的.NET Framework版本與IIS中相應(yīng)site所設(shè)置的.NET Framework版本不相同

          Solution:?jiǎn)?dòng)IIS Manager --> Application Pools --> 選擇相應(yīng)的Name(site) --> 點(diǎn)擊右鍵 --> Advanced Settings --> (General).NET Framwork Version --> 由2.0更改到4.0即可

           

          3:

          Compilation Error

          Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

          Compiler Error Message: CS0016: Could not write to output file 'c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\2ae25944\4afe0277\App_global.asax.ke894tgr.dll' -- 'Access is denied. '

          Source Error:

           
          [No relevant source lines]


          Source File:    Line: 0


          Show Detailed Compiler Output:

          c:\windows\system32\inetsrv> "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe" /t:library /utf8output /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Extensions\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Extensions.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Services\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Web\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel\v4.0_4.0.0.0__b77a5c561934e089\System.ServiceModel.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.Activities.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activation\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activation.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activities.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.ApplicationServices\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.ApplicationServices.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_64\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ComponentModel.DataAnnotations\v4.0_4.0.0.0__31bf3856ad364e35\System.ComponentModel.DataAnnotations.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.WorkflowServices\v4.0_4.0.0.0__31bf3856ad364e35\System.WorkflowServices.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_64\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_64\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.IdentityModel\v4.0_4.0.0.0__b77a5c561934e089\System.IdentityModel.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.DynamicData\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.DynamicData.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll" /out:"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\2ae25944\4afe0277\App_global.asax.ke894tgr.dll" /debug- /optimize+ /w:4 /nowarn:1659;1699;1701 /warnaserror-  "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\2ae25944\4afe0277\App_global.asax.ke894tgr.0.cs" "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\2ae25944\4afe0277\App_global.asax.ke894tgr.1.cs"   Microsoft (R) Visual C# 2010 Compiler version 4.0.30319.1 Copyright (C) Microsoft Corporation. All rights reserved.  error CS0016: Could not write to output file 'c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\2ae25944\4afe0277\App_global.asax.ke894tgr.dll' -- 'Access is denied. ' 




          Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

           

          Cause:對(duì)Windows下的temp文件夾缺少操作權(quán)限

          Solution: 將Windows下的temp文件夾 --> properties --> security --> create owner --> add --> 添加賦予Full Control權(quán)限的Everyone用戶

           

          4:

          Server Error in '/' Application.


          Login failed for user 'IIS APPPOOL\SSO1'.

          Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

          Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'IIS APPPOOL\SSO1'.

          Source Error:

          An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


          Stack Trace:

          [SqlException (0x80131904): Login failed for user 'IIS APPPOOL\SSO1'.]    System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +6333696    System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +412    System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1363    System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +53    System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) +6348638    System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +6348553    System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +352    System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +831    System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +49    System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +6350358    System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +78    System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +1938    System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +89    System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +6353246    System.Data.SqlClient.SqlConnection.Open() +300    System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext context, Boolean revertImpersonate) +150    System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation) +4679471    System.Web.Security.SqlMembershipProvider.GetPasswordWithFormat(String username, Boolean updateLastLoginActivityDate, Int32& status, String& password, Int32& passwordFormat, String& passwordSalt, Int32& failedPasswordAttemptCount, Int32& failedPasswordAnswerAttemptCount, Boolean& isApproved, DateTime& lastLoginDate, DateTime& lastActivityDate) +3720151    System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved, String& salt, Int32& passwordFormat) +189    System.Web.Security.SqlMembershipProvider.ValidateUser(String username, String password) +202    System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(AuthenticateEventArgs e) +225    System.Web.UI.WebControls.Login.AttemptLogin() +166    System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +93    System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +52    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3707 



          Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

           

          Cause:IIS中的Application pool中相應(yīng)site的Identity類型錯(cuò)誤

          Solution: IIS Manager --> Application Pools --> 找到相應(yīng)的site --> 左鍵選擇Advanced Settings --> 將Process Model中的Identity類型換成LocalSystem

          此問(wèn)題(4)的解決方法可以詳 見(jiàn):http://blogs.microsoft.co.il/blogs/shlomo/archive/2009/11/09/system- data-sqlclient-sqlexception-login-failed-for-user-iis-apppool-defaultapppool.aspx

           

          5:

           

          Server Error in '/' Application.
          --------------------------------------------------------------------------------

           

          Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
          Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

           

          Exception Details: System.TypeLoadException: Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

           

          Source Error:

           

          An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

           

          Stack Trace:

           


          [TypeLoadException: Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.]
          System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) +0
          System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, Boolean loadTypeFromPartialName) +314
          System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +95
          System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +124
          System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +76

           

          [ConfigurationErrorsException: Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.]
          System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +11355388
          System.Web.Configuration.Common.ModulesEntry.SecureGetType(String typeName, String propertyName, ConfigurationElement configElement) +69
          System.Web.Configuration.Common.ModulesEntry..ctor(String name, String typeName, String propertyName, ConfigurationElement configElement) +62
          System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) +301
          System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) +1332
          Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleReflectionUtil.GetIntegratedModuleCollection(HttpApplication target, IntPtr appContext) +34
          Microsoft.Web.Infrastructure.DynamicModuleHelper.CriticalStatics.Init(HttpApplication context) +264
          System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +546
          System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +325
          System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +407
          System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +375

           

          [HttpException (0x80004005): Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.]
          System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11524352
          System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
          System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4782309

           

           

           


          --------------------------------------------------------------------------------
          Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

           

           

           

          Cause:.Net Framework4先安裝,IIS后安裝,導(dǎo)致.Net Framework4.0沒(méi)有注冊(cè)到IIS中

           

          Solution: 在Windows的文件夾里找到一個(gè)安裝程序,在CMD里執(zhí)行,具體如下:

                C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -iru
                顯示如下:
                Start installing ASP.NET (4.0.30319).
                ..........
                Finished installing ASP.NET (4.0.30319).
                這樣就可以了。
           
          此問(wèn)題的更詳細(xì)的原因請(qǐng)看: http://msdn.microsoft.com/zh-cn/library/k6h9cz8h.aspx
          posted @ 2013-07-12 13:22 何楊 閱讀(1519) | 評(píng)論 (0)編輯 收藏

          char* HcC21PrintPres::getStringFromDouble(double d){
              char  sbuf2[256];

              sprintf(sbuf2,"%.3f",d);// 保留位數(shù)自己可調(diào)

              for(;sbuf2[strlen(sbuf2) - 1] == '0';){
                  sbuf2[strlen(sbuf2) - 1] = '\0';
                  if(sbuf2[strlen(sbuf2) - 1] == '.'){
                      sbuf2[strlen(sbuf2) - 1] = '\0';
                      break;
                  }
              }

              return sbuf2;
          }
          這種寫法還是挺有意思的.
          posted @ 2013-07-11 10:33 何楊 閱讀(335) | 評(píng)論 (0)編輯 收藏

          http://blog.csdn.net/masikkk/article/details/5634886

          在將各種類型的數(shù)據(jù)構(gòu)造成字符串時(shí),sprintf 的強(qiáng)大功能很少會(huì)讓你失望。由于sprintf 跟printf 在用法上幾乎一樣,只是打印的目的地不同而已,前者打印到字符串中,后者則直接在命令行上輸出。這也導(dǎo)致sprintf 比printf 有用得多。
            sprintf 是個(gè)變參函數(shù),定義如下:
            int sprintf( char *buffer, const char *format [, argument] ... );
            除了前兩個(gè)參數(shù)類型固定外,后面可以接任意多個(gè)參數(shù)。而它的精華,顯然就在第二個(gè)參數(shù):

            (1)格式化字符串上。

            printf 和sprintf 都使用格式化字符串來(lái)指定串的格式,在格式串內(nèi)部使用一些以“%”開頭的格式說(shuō)明符(format specifications)來(lái)占據(jù)一個(gè)位置,在后邊的變參列表中提供相應(yīng)的變量,最終函數(shù)就會(huì)用相應(yīng)位置的變量來(lái)替代那個(gè)說(shuō)明符,產(chǎn)生一個(gè)調(diào)用者想要 的字符串。
            格式化數(shù)字字符串
            sprintf 最常見(jiàn)的應(yīng)用之一莫過(guò)于把整數(shù)打印到字符串中,所以,spritnf 在大多數(shù)場(chǎng)合可以替代itoa。
            如:
            //把整數(shù)123 打印成一個(gè)字符串保存在s 中。
            sprintf(s, "%d", 123); //產(chǎn)生"123"
            可以指定寬度,不足的左邊補(bǔ)空格:
            sprintf(s, "%8d%8d", 123, 4567); //產(chǎn)生:" 123 4567"
            當(dāng)然也可以左對(duì)齊:
            sprintf(s, "%-8d%8d", 123, 4567); //產(chǎn)生:"123 4567"
            也可以按照16 進(jìn)制打印:
            sprintf(s, "%8x", 4567); //小寫16 進(jìn)制,寬度占8 個(gè)位置,右對(duì)齊
            sprintf(s, "%-8X", 4568); //大寫16 進(jìn)制,寬度占8 個(gè)位置,左對(duì)齊
            這樣,一個(gè)整數(shù)的16 進(jìn)制字符串就很容易得到,但我們?cè)诖蛴?6 進(jìn)制內(nèi)容時(shí),通常想要一種左邊補(bǔ)0 的等寬格式,那該怎么做呢?很簡(jiǎn)單,在表示寬度的數(shù)字前面加個(gè)0 就可以了。
            sprintf(s, "%08X", 4567); //產(chǎn)生:"000011D7"
            上面以”%d”進(jìn)行的10 進(jìn)制打印同樣也可以使用這種左邊補(bǔ)0 的方式。
            這里要注意一個(gè)符號(hào)擴(kuò)展的問(wèn)題:比如,假如我們想打印短整數(shù)(short)-1 的內(nèi)存16 進(jìn)制表示形式,在Win32 平臺(tái)上,一個(gè)short 型占2 個(gè)字節(jié),所以我們自然希望用4 個(gè)16 進(jìn)制數(shù)字來(lái)打印它:
            short si = -1;
            sprintf(s, "%04X", si);
            產(chǎn)生“FFFFFFFF”,怎么回事?因?yàn)閟pritnf 是個(gè)變參函數(shù),除了前面兩個(gè)參數(shù)之外,后面的參數(shù)都不是類型安全的,函數(shù)更沒(méi)有辦法僅僅通過(guò)一個(gè)“%X”就能得知當(dāng)初函數(shù)調(diào)用前參數(shù)壓棧時(shí)被壓進(jìn)來(lái)的到底 是個(gè)4 字節(jié)的整數(shù)還是個(gè)2 字節(jié)的短整數(shù),所以采取了統(tǒng)一4 字節(jié)的處理方式,導(dǎo)致參數(shù)壓棧時(shí)做了符號(hào)擴(kuò)展,擴(kuò)展成了32 位的整數(shù)-1,打印時(shí)4 個(gè)位置不夠了,就把32 位整數(shù)-1 的8 位16 進(jìn)制都打印出來(lái)了。
            如果你想看si 的本來(lái)面目,那么就應(yīng)該讓編譯器做0 擴(kuò)展而不是符號(hào)擴(kuò)展(擴(kuò)展時(shí)二進(jìn)制左邊補(bǔ)0 而不是補(bǔ)符號(hào)位):
            sprintf(s, "%04X", (unsigned short)si);
            就可以了。或者:
            unsigned short si = -1;
            sprintf(s, "%04X", si);
            sprintf 和printf 還可以按8 進(jìn)制打印整數(shù)字符串,使用”%o”。注意8 進(jìn)制和16 進(jìn)制都不會(huì)打
            印出負(fù)數(shù),都是無(wú)符號(hào)的,實(shí)際上也就是變量的內(nèi)部編碼的直接的16 進(jìn)制或8 進(jìn)制表示。
            控制浮點(diǎn)數(shù)打印格式
            浮點(diǎn)數(shù)的打印和格式控制是sprintf 的又一大常用功能,浮點(diǎn)數(shù)使用格式符”%f”控制,默認(rèn)保
            留小數(shù)點(diǎn)后6 位數(shù)字,比如:
            sprintf(s, "%f", 3.1415926); //產(chǎn)生"3.141593"
            但有時(shí)我們希望自己控制打印的寬度和小數(shù)位數(shù),這時(shí)就應(yīng)該使用:”%m.nf”格式,其中m 表
            示打印的寬度,n 表示小數(shù)點(diǎn)后的位數(shù)。比如:
            sprintf(s, "%10.3f", 3.1415626); //產(chǎn)生:" 3.142"
            sprintf(s, "%-10.3f", 3.1415626); //產(chǎn)生:"3.142 "
            sprintf(s, "%.3f", 3.1415626); //不指定總寬度,產(chǎn)生:"3.142"
            注意一個(gè)問(wèn)題,你猜
            int i = 100;
            sprintf(s, "%.2f", i);
            會(huì)打出什么東東來(lái)?“100.00”?對(duì)嗎?自己試試就知道了,同時(shí)也試試下面這個(gè):
            sprintf(s, "%.2f", (double)i);
            第一個(gè)打出來(lái)的肯定不是正確結(jié)果,原因跟前面提到的一樣,參數(shù)壓棧時(shí)調(diào)用者并不知道跟i相對(duì)應(yīng)的格式控制符是個(gè)”%f”。而函數(shù)執(zhí)行時(shí)函數(shù)本身則并不 知道當(dāng)年被壓入棧里的是個(gè)整數(shù),于是可憐的保存整數(shù)i 的那4 個(gè)字節(jié)就被不由分說(shuō)地強(qiáng)行作為浮點(diǎn)數(shù)格式來(lái)解釋了,整個(gè)亂套了。不過(guò),如果有人有興趣使用手工編碼一個(gè)浮點(diǎn)數(shù),那么倒可以使用這種方法來(lái)檢驗(yàn)一下你手工編 排的結(jié)果是否正確。
            

              (2)字符/Ascii 碼對(duì)照

            我們知道,在C/C++語(yǔ)言中,char 也是一種普通的scalable 類型,除了字長(zhǎng)之外,它與short,
            int,long 這些類型沒(méi)有本質(zhì)區(qū)別,只不過(guò)被大家習(xí)慣用來(lái)表示字符和字符串而已。(或許當(dāng)年該把
            這個(gè)類型叫做“byte”,然后現(xiàn)在就可以根據(jù)實(shí)際情況,使用byte 或short 來(lái)把char 通過(guò)typedef 定義出來(lái),這樣更合適些)于是,使用”%d”或者”%x”打印一個(gè)字符,便能得出它的10 進(jìn)制或16 進(jìn)制的ASCII 碼;反過(guò)來(lái),使用”%c”打印一個(gè)整數(shù),便可以看到它所對(duì)應(yīng)的ASCII 字符。以下程序段把所有可見(jiàn)字符的ASCII 碼對(duì)照表打印到屏幕上(這里采用printf,注意”#”與”%X”合用時(shí)自動(dòng)為16 進(jìn)制數(shù)增加”0X”前綴):
            for(int i = 32; i < 127; i++) {
            printf("[ %c ]: %3d 0x%#04X/n", i, i, i);
            }


            (3)連接字符串

            sprintf 的格式控制串中既然可以插入各種東西,并最終把它們“連成一串”,自然也就能夠連
            接字符串,從而在許多場(chǎng)合可以替代strcat,但sprintf 能夠一次連接多個(gè)字符串(自然也可以同時(shí)
            在它們中間插入別的內(nèi)容,總之非常靈活)。比如:
            char* who = "I";
            char* whom = "CSDN";
            sprintf(s, "%s love %s.", who, whom); //產(chǎn)生:"I love CSDN. "
            strcat 只能連接字符串(一段以’’結(jié)尾的字符數(shù)組或叫做字符緩沖,null-terminated-string),但有時(shí)我們有兩段字符緩沖區(qū),他們并不是以 ’’結(jié)尾。比如許多從第三方庫(kù)函數(shù)中返回的字符數(shù)組,從硬件或者網(wǎng)絡(luò)傳輸中讀進(jìn)來(lái)的字符流,它們未必每一段字符序列后面都有個(gè)相應(yīng)的’’來(lái)結(jié)尾。如果直接 連接,不管是sprintf 還是strcat 肯定會(huì)導(dǎo)致非法內(nèi)存操作,而strncat 也至少要求第一個(gè)參數(shù)是個(gè)null-terminated-string,那該怎么辦呢?我們自然會(huì)想起前面介紹打印整數(shù)和浮點(diǎn)數(shù)時(shí)可以指定寬度,字符串 也一樣的。比如:
            char a1[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G'};
            char a2[] = {'H', 'I', 'J', 'K', 'L', 'M', 'N'};
            如果:
            sprintf(s, "%s%s", a1, a2); //Don't do that!
            十有八九要出問(wèn)題了。是否可以改成:
            sprintf(s, "%7s%7s", a1, a2);
            也沒(méi)好到哪兒去,正確的應(yīng)該是:
            sprintf(s, "%.7s%.7s", a1, a2);//產(chǎn)生:"ABCDEFGHIJKLMN"
            這可以類比打印浮點(diǎn)數(shù)的”%m.nf”,在”%m.ns”中,m 表示占用寬度(字符串長(zhǎng)度不足時(shí)補(bǔ)空格,超出了則按照實(shí)際寬度打印),n 才表示從相應(yīng)的字符串中最多取用的字符數(shù)。通常在打印字符串時(shí)m 沒(méi)什么大用,還是點(diǎn)號(hào)后面的n 用的多。自然,也可以前后都只取部分字符:
            sprintf(s, "%.6s%.5s", a1, a2);//產(chǎn)生:"ABCDEFHIJKL"
            在許多時(shí)候,我們或許還希望這些格式控制符中用以指定長(zhǎng)度信息的數(shù)字是動(dòng)態(tài)的,而不是靜態(tài)指定的,因?yàn)樵S多時(shí)候,程序要到運(yùn)行時(shí)才會(huì)清楚到底需要取字 符數(shù)組中的幾個(gè)字符,這種動(dòng)態(tài)的寬度/精度設(shè)置功能在sprintf 的實(shí)現(xiàn)中也被考慮到了,sprintf 采用”*”來(lái)占用一個(gè)本來(lái)需要一個(gè)指定寬度或精度的常數(shù)數(shù)字的位置,同樣,而實(shí)際的寬度或精度就可以和其它被打印的變量一樣被提供出來(lái),于是,上面的例子 可以變成:
            sprintf(s, "%.*s%.*s", 7, a1, 7, a2);
            或者:
            sprintf(s, "%.*s%.*s", sizeof(a1), a1, sizeof(a2), a2);
            實(shí)際上,前面介紹的打印字符、整數(shù)、浮點(diǎn)數(shù)等都可以動(dòng)態(tài)指定那些常量值,比如:
            sprintf(s, "%-*d", 4, 'A'); //產(chǎn)生"65 "
            sprintf(s, "%#0*X", 8, 128); //產(chǎn)生"0X000080","#"產(chǎn)生0X
            sprintf(s, "%*.*f", 10, 2, 3.1415926); //產(chǎn)生" 3.14"


            (4)打印地址信息

            有時(shí)調(diào)試程序時(shí),我們可能想查看某些變量或者成員的地址,由于地址或者指針也不過(guò)是個(gè)32 位的數(shù),你完全可以使用打印無(wú)符號(hào)整數(shù)的”%u”把他們打印出來(lái):
            sprintf(s, "%u", &i);
            不過(guò)通常人們還是喜歡使用16 進(jìn)制而不是10 進(jìn)制來(lái)顯示一個(gè)地址:
            sprintf(s, "%08X", &i);
            然而,這些都是間接的方法,對(duì)于地址打印,sprintf 提供了專門的”%p”:
            sprintf(s, "%p", &i);
            我覺(jué)得它實(shí)際上就相當(dāng)于:
            sprintf(s, "%0*x", 2 * sizeof(void *), &i);


            (5)利用sprintf 的返回值

            較少有人注意printf/sprintf 函數(shù)的返回值,但有時(shí)它卻是有用的,spritnf 返回了本次函數(shù)調(diào)用
            最終打印到字符緩沖區(qū)中的字符數(shù)目。也就是說(shuō)每當(dāng)一次sprinf 調(diào)用結(jié)束以后,你無(wú)須再調(diào)用一次
            strlen 便已經(jīng)知道了結(jié)果字符串的長(zhǎng)度。如:
            int len = sprintf(s, "%d", i);
            對(duì)于正整數(shù)來(lái)說(shuō),len 便等于整數(shù)i 的10 進(jìn)制位數(shù)。
            下面的是個(gè)完整的例子,產(chǎn)生10 個(gè)[0, 100)之間的隨機(jī)數(shù),并將他們打印到一個(gè)字符數(shù)組s 中,
            以逗號(hào)分隔開。
            #include
            #include
            #include
            int main() {
            srand(time(0));
            char s[64];
            int offset = 0;
            for(int i = 0; i < 10; i++) {
            offset += sprintf(s + offset, "%d,", rand() % 100);
            }
            s[offset - 1] = '/n';//將最后一個(gè)逗號(hào)換成換行符。
            printf(s);
            return 0;
            }
            設(shè)想當(dāng)你從數(shù)據(jù)庫(kù)中取出一條記錄,然后希望把他們的各個(gè)字段按照某種規(guī)則連接成一個(gè)字
            符串時(shí),就可以使用這種方法,從理論上講,他應(yīng)該比不斷的strcat 效率高,因?yàn)閟trcat 每次調(diào)用
            都需要先找到最后的那個(gè)’’的位置,而在上面給出的例子中,我們每次都利用sprintf 返回值把這
            個(gè)位置直接記下來(lái)了。
            使用sprintf 的常見(jiàn)問(wèn)題
            sprintf 是個(gè)變參函數(shù),使用時(shí)經(jīng)常出問(wèn)題,而且只要出問(wèn)題通常就是能導(dǎo)致程序崩潰的內(nèi)存訪
            問(wèn)錯(cuò)誤,但好在由sprintf 誤用導(dǎo)致的問(wèn)題雖然嚴(yán)重,卻很容易找出,無(wú)非就是那么幾種情況,通
            常用眼睛再把出錯(cuò)的代碼多看幾眼就看出來(lái)了。
            ?? 緩沖區(qū)溢出
            第一個(gè)參數(shù)的長(zhǎng)度太短了,沒(méi)的說(shuō),給個(gè)大點(diǎn)的地方吧。當(dāng)然也可能是后面的參數(shù)的問(wèn)
            題,建議變參對(duì)應(yīng)一定要細(xì)心,而打印字符串時(shí),盡量使用”%.ns”的形式指定最大字符數(shù)。
            ?? 忘記了第一個(gè)參數(shù)
            低級(jí)得不能再低級(jí)問(wèn)題,用printf 用得太慣了。//偶就常犯。:。(
            ?? 變參對(duì)應(yīng)出問(wèn)題
            通常是忘記了提供對(duì)應(yīng)某個(gè)格式符的變參,導(dǎo)致以后的參數(shù)統(tǒng)統(tǒng)錯(cuò)位,檢查檢查吧。尤
            其是對(duì)應(yīng)”*”的那些參數(shù),都提供了嗎?不要把一個(gè)整數(shù)對(duì)應(yīng)一個(gè)”%s”,編譯器會(huì)覺(jué)得你
            欺她太甚了(編譯器是obj 和exe 的媽媽,應(yīng)該是個(gè)女的,:P)。
            strftime
            sprnitf 還有個(gè)不錯(cuò)的表妹:strftime,專門用于格式化時(shí)間字符串的,用法跟她表哥很像,也
            是一大堆格式控制符,只是畢竟小姑娘家心細(xì),她還要調(diào)用者指定緩沖區(qū)的最大長(zhǎng)度,可能是為
            了在出現(xiàn)問(wèn)題時(shí)可以推卸責(zé)任吧。這里舉個(gè)例子:
            time_t t = time(0);
            //產(chǎn)生"YYYY-MM-DD hh:mm:ss"格式的字符串。
            char s[32];
            strftime(s, sizeof(s), "%Y-%m-%d %H:%M:%S", localtime(&t));
            sprintf 在MFC 中也能找到他的知音:CString::Format,strftime 在MFC 中自然也有她的同道:
            CTime::Format,這一對(duì)由于從面向?qū)ο竽睦锏玫搅速澲靡詫懗龅拇a更覺(jué)優(yōu)雅。

           

           

           

           

          sprintf 用法總結(jié)(2009-08-25 09:36:24)標(biāo)簽:it   分類:C++
            sprintf,將各種類型的數(shù)據(jù)夠造成字符串。

            sprintf是個(gè)變參函數(shù),int sprintf(char *buffer,const char *format[,argument]...);除了前兩個(gè)參數(shù)類型固定外,后面可以接任意多個(gè)參數(shù),而它的精華,則在第二個(gè)參數(shù):格式化字符串上。

            printf和sprintf都使用格式化字符串來(lái)指定串的格式,在格式串內(nèi)部使 用一些以“%”開頭的格式說(shuō)明符(format specification)來(lái)占據(jù)一個(gè)位置,在后邊的變參列表中提供相應(yīng)的變量,最終函數(shù)就會(huì)用相應(yīng)位置的變量來(lái)替代那個(gè)說(shuō)明符,產(chǎn)生一個(gè)調(diào)用者想要的 字符串。

           一、格式化數(shù)字字符串

            sprintf最常見(jiàn)的應(yīng)用之一莫過(guò)于把整數(shù)打印到字符串中,所以sprintf在大多數(shù)場(chǎng)合可以替代itoa.

              %-8d 代表寬度八位,左對(duì)齊(沒(méi)有負(fù)號(hào)為右對(duì)齊),整數(shù)的十進(jìn)制

            %x小寫16進(jìn)制  %X大寫16進(jìn)制

              符號(hào)擴(kuò)展問(wèn)題:參數(shù)壓棧默認(rèn)四字節(jié),即8位16進(jìn)制。應(yīng)該讓編譯器做0擴(kuò)展而不是符號(hào)擴(kuò)展。

            如  sprintf(s,"%04X",(unsigned short)si);

              %o 8進(jìn)制格式化字符串。

            控制浮點(diǎn)數(shù)打印格式,使用格式符"%f"控制,默認(rèn)保留小數(shù)點(diǎn)后6位數(shù)字。

            %m.nf m表示打印的寬度,n表示小數(shù)點(diǎn)后的位數(shù)

            sprintf(s,"%m.nf",i)其中i 必須為浮點(diǎn)類型的

          二、字符/ASCII碼對(duì)照

            %c打印一個(gè)整數(shù),可以看到整數(shù)所對(duì)應(yīng)的ASCII值

            for(int i=32 ;i<127;i++)
            {
              printf("[%c]:%3d 0x%#04X/n",i,i,i);
            }

           #與%X合用時(shí)自動(dòng)為16進(jìn)制數(shù)增加“0X”前綴。

          三、連接字符串

           可以在許多場(chǎng)合替代strcat,sprintf能夠一次連接多個(gè)字符串。

           %s可以參照浮點(diǎn)數(shù)控制的%m.n m表示寬度,n表示從相應(yīng)的字符串中最多取用的字符數(shù),通常m沒(méi)什么用。

            對(duì)于動(dòng)態(tài)的,可以采用sprintf(s,"%.*s%.*s",7,a1,7,a2)或sprintf(s,"%.*s%.*s",sizeof(a1),a1,sizeof(a2),a2);  

          四、打印地址信息

          有時(shí)調(diào)試程序時(shí),我們可能想查看某些變量或者成員的地址,由于地址或者指針也不過(guò)是個(gè)32 位的數(shù),你完全可以使用打印無(wú)符號(hào)整數(shù)的”%u”把他們打印出來(lái):
          sprintf(s, "%u", &i);
          不過(guò)通常人們還是喜歡使用16 進(jìn)制而不是10 進(jìn)制來(lái)顯示一個(gè)地址:
          sprintf(s, "%08X", &i);
          然而,這些都是間接的方法,對(duì)于地址打印,sprintf 提供了專門的”%p”:
          sprintf(s, "%p", &i);
          我覺(jué)得它實(shí)際上就相當(dāng)于:
          sprintf(s, "%0*x", 2 * sizeof(void *), &i);

          五、返回值

          返回了本次函數(shù)調(diào)用最終打印到字符緩沖區(qū)中的字符數(shù)目。
          六、strftime

          專門用于格式化時(shí)間字符串。需調(diào)用者指定緩沖區(qū)的最大長(zhǎng)度。

          strftime(s,sizeof(s),"%Y-%m-%d %H:%M:%S",localtime(&t));
          posted @ 2013-07-10 15:31 何楊 閱讀(286) | 評(píng)論 (0)編輯 收藏

          http://sddhn.blog.163.com/blog/static/1281877920129191574926/


          在DB2中從客戶端訪問(wèn)服務(wù)器端的數(shù)據(jù)庫(kù)時(shí),不能直接用connect命令,而必須先建立通信node,再在node的基礎(chǔ)上建立數(shù)據(jù)庫(kù)連接。在命令行的具體操作如下:
          ->db2 catalog tcpip node ${nodeName} remote ${serverName} server ${portNumber} 
          ->db2 catalog db ${dbName} as ${dbAlias} at node ${nodeName} 
          ->db2 connect to ${dbAlias} user ${userName} using ${passWord}
          ->db2 terminate
          說(shuō)明:
          ${nodeName}:任意起的一個(gè)結(jié)點(diǎn)名,注意長(zhǎng)度限制
          ${serverName}:遠(yuǎn)程數(shù)據(jù)庫(kù)所在服務(wù)器名稱或IP地址
          ${portNumber} :遠(yuǎn)程數(shù)據(jù)庫(kù)端口號(hào)
          ${dbName}:遠(yuǎn)程數(shù)據(jù)庫(kù)的名字
          ${dbAlias}:編目到本地后的數(shù)據(jù)庫(kù)別名
          ${userName}:連接數(shù)據(jù)庫(kù)用戶名
          ${passWord}:連接數(shù)據(jù)庫(kù)密碼
          其他相關(guān)一些重要的DB2命令
            1. 查看本地節(jié)點(diǎn)目錄
            命令窗口中輸入:db2 list node directory
            2. 編目一個(gè)TCP/IP節(jié)點(diǎn)
             命令窗口:db2 catalog tcpip node <node_name> remote <hostname|ip_address> server <svcname|port_number> ostype <OS2|AIX|WIN95|NT|HPUX|SUN|MVS|OS400|VM|VSE|SCO|SGI|LINUX|DYNIX>

          Eg: Open a command shell and input the commands below:

          db2 catalog tcpip node koubeSvr remote 9.119.100.222 server 50000

          db2 catalog db KOUBE23 as KOUBE23 at node koubeSvr

            3. 取消節(jié)點(diǎn)編目
            db2 uncatalog node <node_name>
            4. 查看系統(tǒng)數(shù)據(jù)庫(kù)目錄
            db2 list database directory
            5. 查看本地?cái)?shù)據(jù)庫(kù)目錄
            db2 list database directory on <盤符>
            在本地?cái)?shù)據(jù)庫(kù)目錄中有而系統(tǒng)數(shù)據(jù)庫(kù)目錄中沒(méi)有的數(shù)據(jù)庫(kù)不能訪問(wèn),可以在控制中心中選中<數(shù)據(jù)庫(kù)>右鍵單擊選擇添加,然后輸入需要添加的數(shù)據(jù)庫(kù)名稱或者點(diǎn)擊刷新按鈕選擇數(shù)據(jù)庫(kù),加入數(shù)據(jù)庫(kù)后即可以訪問(wèn)。
            6. 編目數(shù)據(jù)庫(kù)
            db2 catalog database <db_name> as <db_alias> at node <node_name>
            7. 取消數(shù)據(jù)庫(kù)編目
            db2 uncatalog database <db_name>
            8. 測(cè)試遠(yuǎn)程數(shù)據(jù)庫(kù)的連接
            db2 connect to <db_alias> user <user_id> using <password>
          posted @ 2013-07-08 15:23 何楊 閱讀(399) | 評(píng)論 (0)編輯 收藏

          工具:
          這個(gè)工具用于將ASM文件編譯.
          http://www.aygfsteel.com/Files/heyang/nasm-2.07-installer.rar

          建議使用Notepad++書寫asm,然后用命令行編譯:
          >nasm a.asm -o a.com

          這個(gè)工具能將BIN寫入軟盤扇區(qū):
          http://www.aygfsteel.com/Files/heyang/FloppyWriter.zip

          以下是一個(gè)例程:
          %define _BOOT_DEBUG_
          %ifdef _BOOT_DEBUG_
              org 0100h
          %else
              org 07c00h
          %endif
              mov ax,cs
              mov ds,ax
              mov es,ax
              call DispStr;
              jmp $;
          DispStr:
              mov ax,BootMessage
              mov bp,ax
              mov cx,
          32
              mov ax,01301h
              mov bx,000ch
              mov dl,
          0
              
          int 10h
              ret
          BootMessage:    db 
          "Hello,OS world!XXXXXX is here."
          times 
          510-($-$$) db 0;
          dw 
          0xaa55;
          posted @ 2013-05-30 20:40 何楊 閱讀(187) | 評(píng)論 (0)編輯 收藏

          /**********************************************
          * 獲取相對(duì)于今天的日期
          * 2013年4月29日22:21:23
          *********************************************
          */
          function GetDateStr(AddDayCount) {
              
          var dd = new Date();
              dd.setDate(dd.getDate()
          +AddDayCount);//獲取AddDayCount天后的日期
              var y = dd.getFullYear();
              
              
          var m = dd.getMonth()+1;//獲取當(dāng)前月份的日期
              m=parseInt(m,10);
              
          if(m<10){
                  m
          ="0"+m;
              }
              
              
          var d = dd.getDate();
              d
          =parseInt(d,10);
              
          if(d<10){
                  d
          ="0"+d;
              }
              
              
          return y+"-"+m+"-"+d;
          }

          示例:
          var today=GetDateStr(0);
          var yesterday=GetDateStr(-1);
          var thedaybeforeyesterday=GetDateStr(-2);

          posted @ 2013-05-06 16:56 何楊 閱讀(261) | 評(píng)論 (0)編輯 收藏

          1.dom初始化
          $(document).ready(
              function(){
                  ...// 這里寫初始化
              }
          );

          2.給所有class為channel的元素設(shè)定點(diǎn)擊事件.
          $('.channel').click(
               function(){
                   ...
              }
          );

          3.給id=menuDiv下的ul下的li中的設(shè)定點(diǎn)擊事件.
          $("#menuDiv>ul>li>a").click{   
              function(){
                   ...
              }
          );
          posted @ 2013-05-02 21:18 何楊 閱讀(293) | 評(píng)論 (0)編輯 收藏

          代碼:
          <div class="XXX">
              <img class="X" src="XX">
          </div>

          方法:
          設(shè)置div與img等高,其height=line-height,這樣Img就被DIV夾在中間了.
          再設(shè)置div的margin-top=margin-bottom,這樣上下外邊距相等,img就隨著div被夾在中間了.
          posted @ 2013-04-30 21:10 何楊 閱讀(394) | 評(píng)論 (0)編輯 收藏

          1.調(diào)用new Object,如
          var obj=new Object();
          obj創(chuàng)建出來(lái)后沒(méi)有任何屬性或方法,需要手工進(jìn)行添加
          obj.property=XX;
          obj.method=function(){...};

          2.用大括弧{}來(lái)直接描述屬性或方法
          var obj={property01:value01,property02:value02,...};

          3.自定義一個(gè)構(gòu)建函數(shù),然后用new來(lái)創(chuàng)建
          function func(value01,value02,...,value0n){
               this.property01=value01;
               this.property02=value02;
               ...
               this.property0n=value0n;
          }

          var obj=new func(v1,v2,..,vn);
          posted @ 2013-04-29 16:10 何楊 閱讀(286) | 評(píng)論 (0)編輯 收藏

          僅列出標(biāo)題
          共28頁(yè): 上一頁(yè) 1 2 3 4 5 6 7 8 9 下一頁(yè) Last 
          主站蜘蛛池模板: 宁津县| 涿州市| 博爱县| 繁昌县| 洪江市| 潜山县| 建昌县| 高台县| 蚌埠市| 普定县| 古丈县| 扎囊县| 揭西县| 乌兰浩特市| 阿克| 巴东县| 镇安县| 高青县| 原阳县| 贵定县| 剑川县| 宽城| 博野县| 巴林右旗| 连城县| 德安县| 博白县| 阳春市| 平塘县| 光泽县| 东乌珠穆沁旗| 凌海市| 泸定县| 天等县| 扶余县| 麦盖提县| 平安县| 即墨市| 得荣县| 张家口市| 丰宁|