<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    當柳上原的風吹向天際的時候...

    真正的快樂來源于創造

      BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
      368 Posts :: 1 Stories :: 201 Comments :: 0 Trackbacks

    #

        FROM:

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



       系統環境:windows 7 旗艦版

          軟件版本:IBM DB2數據庫(DB2_ESE_97_Win_x86)

          準備工作:關閉防火墻及殺軟等安全防護軟件

         本文是事后整理的,可以在循序上有些亂,有些步奏也是省略的,省略的都是選擇默認選項

    1.   運行安裝目錄下的  setup.exe 程序,點擊“下一步”

    2.    選擇“我接受許可證協議中的全部條款”,點擊“下一步”

    3.  根據自己需求選擇安裝方式,我選擇“典型安裝”,點擊“下一步”

    4.   選擇“在此計算機上安裝DB2Enterprise Server Edition ” ,點擊“下一步”

    5.    更改安裝路徑,點擊“下一步”

    6.    默認選項,點擊“下一步”

     

    7.    設置密碼,點擊“下一步”

     

    8. 不勾選“設置DB2服務器以發送通知”,點擊“下一步”

    9.    勾選“啟動操作系統安全性”,點擊“下一步”

    10.   勾選“準備DB2工具目錄”,點擊“下一步”

     

    11.  點擊“下一步”,進行安裝

      安裝成功后會有提示



    我安裝的時候出現以下問題:
    posted @ 2013-07-14 00:11 何楊 閱讀(337) | 評論 (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) 沒有向iis中注冊.net framework(引起的原因之一:先安裝了.net framework,后安裝的iis)

        2) 沒有對IIS中所配置的site有足夠的操作權限(Modify權限)

    Solution:

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

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

        2) IIS Manager --> Sites --> 相應的site --> 點擊右鍵 --> Edit Permissions --> Security --> Group or user names --> Edit --> Add --> 添加賦予Full Control權限(實質上帶有Modify的權限就可以)的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:當前程序所運行的.NET Framework版本與IIS中相應site所設置的.NET Framework版本不相同

    Solution:啟動IIS Manager --> Application Pools --> 選擇相應的Name(site) --> 點擊右鍵 --> 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:對Windows下的temp文件夾缺少操作權限

    Solution: 將Windows下的temp文件夾 --> properties --> security --> create owner --> add --> 添加賦予Full Control權限的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中相應site的Identity類型錯誤

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

    此問題(4)的解決方法可以詳 見: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后安裝,導致.Net Framework4.0沒有注冊到IIS中

     

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

          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).
          這樣就可以了。
     
    此問題的更詳細的原因請看: http://msdn.microsoft.com/zh-cn/library/k6h9cz8h.aspx
    posted @ 2013-07-12 13:22 何楊 閱讀(1512) | 評論 (0)編輯 收藏

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

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

        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 何楊 閱讀(328) | 評論 (0)編輯 收藏

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

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

      (1)格式化字符串上。

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

        (2)字符/Ascii 碼對照

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


      (3)連接字符串

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


      (4)打印地址信息

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


      (5)利用sprintf 的返回值

      較少有人注意printf/sprintf 函數的返回值,但有時它卻是有用的,spritnf 返回了本次函數調用
      最終打印到字符緩沖區中的字符數目。也就是說每當一次sprinf 調用結束以后,你無須再調用一次
      strlen 便已經知道了結果字符串的長度。如:
      int len = sprintf(s, "%d", i);
      對于正整數來說,len 便等于整數i 的10 進制位數。
      下面的是個完整的例子,產生10 個[0, 100)之間的隨機數,并將他們打印到一個字符數組s 中,
      以逗號分隔開。
      #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';//將最后一個逗號換成換行符。
      printf(s);
      return 0;
      }
      設想當你從數據庫中取出一條記錄,然后希望把他們的各個字段按照某種規則連接成一個字
      符串時,就可以使用這種方法,從理論上講,他應該比不斷的strcat 效率高,因為strcat 每次調用
      都需要先找到最后的那個’’的位置,而在上面給出的例子中,我們每次都利用sprintf 返回值把這
      個位置直接記下來了。
      使用sprintf 的常見問題
      sprintf 是個變參函數,使用時經常出問題,而且只要出問題通常就是能導致程序崩潰的內存訪
      問錯誤,但好在由sprintf 誤用導致的問題雖然嚴重,卻很容易找出,無非就是那么幾種情況,通
      常用眼睛再把出錯的代碼多看幾眼就看出來了。
      ?? 緩沖區溢出
      第一個參數的長度太短了,沒的說,給個大點的地方吧。當然也可能是后面的參數的問
      題,建議變參對應一定要細心,而打印字符串時,盡量使用”%.ns”的形式指定最大字符數。
      ?? 忘記了第一個參數
      低級得不能再低級問題,用printf 用得太慣了。//偶就常犯。:。(
      ?? 變參對應出問題
      通常是忘記了提供對應某個格式符的變參,導致以后的參數統統錯位,檢查檢查吧。尤
      其是對應”*”的那些參數,都提供了嗎?不要把一個整數對應一個”%s”,編譯器會覺得你
      欺她太甚了(編譯器是obj 和exe 的媽媽,應該是個女的,:P)。
      strftime
      sprnitf 還有個不錯的表妹:strftime,專門用于格式化時間字符串的,用法跟她表哥很像,也
      是一大堆格式控制符,只是畢竟小姑娘家心細,她還要調用者指定緩沖區的最大長度,可能是為
      了在出現問題時可以推卸責任吧。這里舉個例子:
      time_t t = time(0);
      //產生"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,這一對由于從面向對象哪里得到了贊助,用以寫出的代碼更覺優雅。

     

     

     

     

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

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

      printf和sprintf都使用格式化字符串來指定串的格式,在格式串內部使 用一些以“%”開頭的格式說明符(format specification)來占據一個位置,在后邊的變參列表中提供相應的變量,最終函數就會用相應位置的變量來替代那個說明符,產生一個調用者想要的 字符串。

     一、格式化數字字符串

      sprintf最常見的應用之一莫過于把整數打印到字符串中,所以sprintf在大多數場合可以替代itoa.

        %-8d 代表寬度八位,左對齊(沒有負號為右對齊),整數的十進制

      %x小寫16進制  %X大寫16進制

        符號擴展問題:參數壓棧默認四字節,即8位16進制。應該讓編譯器做0擴展而不是符號擴展。

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

        %o 8進制格式化字符串。

      控制浮點數打印格式,使用格式符"%f"控制,默認保留小數點后6位數字。

      %m.nf m表示打印的寬度,n表示小數點后的位數

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

    二、字符/ASCII碼對照

      %c打印一個整數,可以看到整數所對應的ASCII值

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

     #與%X合用時自動為16進制數增加“0X”前綴。

    三、連接字符串

     可以在許多場合替代strcat,sprintf能夠一次連接多個字符串。

     %s可以參照浮點數控制的%m.n m表示寬度,n表示從相應的字符串中最多取用的字符數,通常m沒什么用。

      對于動態的,可以采用sprintf(s,"%.*s%.*s",7,a1,7,a2)或sprintf(s,"%.*s%.*s",sizeof(a1),a1,sizeof(a2),a2);  

    四、打印地址信息

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

    五、返回值

    返回了本次函數調用最終打印到字符緩沖區中的字符數目。
    六、strftime

    專門用于格式化時間字符串。需調用者指定緩沖區的最大長度。

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

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


    在DB2中從客戶端訪問服務器端的數據庫時,不能直接用connect命令,而必須先建立通信node,再在node的基礎上建立數據庫連接。在命令行的具體操作如下:
    ->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
    說明:
    ${nodeName}:任意起的一個結點名,注意長度限制
    ${serverName}:遠程數據庫所在服務器名稱或IP地址
    ${portNumber} :遠程數據庫端口號
    ${dbName}:遠程數據庫的名字
    ${dbAlias}:編目到本地后的數據庫別名
    ${userName}:連接數據庫用戶名
    ${passWord}:連接數據庫密碼
    其他相關一些重要的DB2命令
      1. 查看本地節點目錄
      命令窗口中輸入:db2 list node directory
      2. 編目一個TCP/IP節點
       命令窗口: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. 取消節點編目
      db2 uncatalog node <node_name>
      4. 查看系統數據庫目錄
      db2 list database directory
      5. 查看本地數據庫目錄
      db2 list database directory on <盤符>
      在本地數據庫目錄中有而系統數據庫目錄中沒有的數據庫不能訪問,可以在控制中心中選中<數據庫>右鍵單擊選擇添加,然后輸入需要添加的數據庫名稱或者點擊刷新按鈕選擇數據庫,加入數據庫后即可以訪問。
      6. 編目數據庫
      db2 catalog database <db_name> as <db_alias> at node <node_name>
      7. 取消數據庫編目
      db2 uncatalog database <db_name>
      8. 測試遠程數據庫的連接
      db2 connect to <db_alias> user <user_id> using <password>
    posted @ 2013-07-08 15:23 何楊 閱讀(391) | 評論 (0)編輯 收藏

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

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

    這個工具能將BIN寫入軟盤扇區:
    http://www.tkk7.com/Files/heyang/FloppyWriter.zip

    以下是一個例程:
    %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 何楊 閱讀(182) | 評論 (0)編輯 收藏

    /**********************************************
    * 獲取相對于今天的日期
    * 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;//獲取當前月份的日期
        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 何楊 閱讀(254) | 評論 (0)編輯 收藏

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

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

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

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

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

    1.調用new Object,如
    var obj=new Object();
    obj創建出來后沒有任何屬性或方法,需要手工進行添加
    obj.property=XX;
    obj.method=function(){...};

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

    3.自定義一個構建函數,然后用new來創建
    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 何楊 閱讀(281) | 評論 (0)編輯 收藏

    僅列出標題
    共28頁: 上一頁 1 2 3 4 5 6 7 8 9 下一頁 Last 
    主站蜘蛛池模板: 亚洲AV成人一区二区三区观看| 日韩亚洲AV无码一区二区不卡 | 亚洲综合一区国产精品| 亚洲视频在线免费观看| 亚洲av片劲爆在线观看| 免费精品无码AV片在线观看| 亚洲福利一区二区精品秒拍| 免费h片在线观看网址最新| 色噜噜亚洲男人的天堂| 免费看a级黄色片| 日韩国产精品亚洲а∨天堂免| 国产成人免费一区二区三区| 成人特级毛片69免费观看| 亚洲人成网站观看在线播放| 亚洲一区二区三区免费| 国产av无码专区亚洲av桃花庵| 午夜理伦剧场免费| 中文字幕无码精品亚洲资源网久久 | 亚洲视频一区在线| 在线观看免费a∨网站| 特级aaaaaaaaa毛片免费视频| 中文字幕一精品亚洲无线一区| 99精品视频免费观看| 456亚洲人成在线播放网站| 国产禁女女网站免费看| 99热在线日韩精品免费| 亚洲国产品综合人成综合网站| 国产福利免费观看| 国产啪精品视频网站免费尤物| 亚洲精品国产情侣av在线| 国产男女猛烈无遮挡免费网站 | 亚洲av无码片区一区二区三区| 在线日韩av永久免费观看| 黄桃AV无码免费一区二区三区| 久久精品国产亚洲AV电影| 日韩免费视频网站| 日本免费污片中国特一级| 亚洲成av人片在www鸭子| 亚洲AV无码一区东京热久久| 青青草免费在线视频| 中文在线免费视频|