Time of Update: 2018-12-07
C#和VB中浮點數到整數的轉換 /* C# int a1 = (int)(3.22324);//3 int a2 = (int)(3.82324);//3 int a3 = (int)(-3.22324);//3 int a4 = (int)(-3.82324);//3 int b1 = (int)Math.Round(3.22324);//3 int b2 = (int)Math.Round(3.82324);//4 int b3 = (
Time of Update: 2018-12-07
以HTTP GET為例,需要去伺服器擷取網頁內容,為防止出錯,重試3次,在最後一次重試失敗時才拋出異常,前兩次的異常我們都會忽略。在C#中通常這樣處理:for(int i=0;i<3;i++){ try { ... } catch(Exception e) { if(i==2)throw e; }}有幾年沒用C++Builder了,當我把這段代碼搬到C++Builder中時,最初是這樣:for(int i=0;i<3;i++){ try { ...
Time of Update: 2018-12-07
有人說對於C/C++程式員說,學習OC是難以忍受的,這話說的也不無道理,關鍵看你能否堅持下去,過了過渡期就好了。 當初我第一個IPHONE程式,使用OC的感覺,真的是很噁心,很不習慣,我還是做C嵌入式開發的。 但是這個項目完成後,後面再做別的IPHONE程式,感覺就好多了,現在用起來基本沒有障礙了。反而是在寫C/C++程式的字串是經常打出@""的樣式,呵呵。 不要為了OC而學OC,要為了完成一個項目而學習OC,對於其它語言也一樣,我就是這麼認為的。
Time of Update: 2018-12-07
整合了使用新浪微博帳號登入第三方網站的服務,也就是說:當你來到一個新的網站的時候,無需註冊,使用新浪微博的賬戶即可登入。 這種串連微博的服務是微博開放平台提供給第三方網站的一種服務。這種服務包括身份認證、使用者關係以及內容傳播。串連微博允許訪問第三方網站的使用者通過微博帳號進行登入,分享內容,同步資訊。通過使用串連微博的服務,第三方網站不僅能夠降低使用者註冊門檻,也能夠讓使用者更快的與微博上的粉絲分享網站內容,從而提升網站的訪問量、網站資訊的進一步傳播與分享。 具體效果是:1.
Time of Update: 2018-12-07
今天給同事的代碼做了一個CodeReview,發現了一些潛在的問題/bug,有很多是基於C#的文法糖很炫而又不理解其深層含義導致。下面就舉個例子,是關於C#的閉包的,新手很容易犯,你看看下面的程式,能不能寫出程式的運行結果呢? using System;namespace ConsoleApplication2{ class Program { static void Main(string[] args) { var t =
Time of Update: 2018-12-07
-- =============================================-- Author: <Author,,Name>-- Create date: <Create Date,,>-- Description:sql函數實現C#Split的功能-- =============================================set ANSI_NULLS ONset QUOTED_IDENTIFIER ONgoALTER
Time of Update: 2018-12-07
C語言程式的記憶體配置方式1.記憶體配置方式
Time of Update: 2018-12-07
string類型轉成byte[]:byte[] byteArray = System.Text.Encoding.Default.GetBytes ( str );反過來,byte[]轉成string:string str = System.Text.Encoding.Default.GetString ( byteArray );其它編碼方式的,如System.Text.UTF8Encoding,System.Text.UnicodeEncoding
Time of Update: 2018-12-07
第一種方法:string s=abcdeabcdeabcde;string[] sArray=s.Split(c) ;foreach(string i in sArray) Console.WriteLine(i.ToString());輸出下面的結果:abdeabdeabde第二種方法:我們看到了結果是以一個指定的字元進行的分割。使用另一種構造方法對多個字元進行分割: string s=abcdeabcdeabcdestring[] sArray1=s.Split(new
Time of Update: 2018-12-07
醋罈酸味灌 味落跳福豆 共44個運算子 醋-初等,4個: ( ) [ ] -> 指向結構體成員 . 結構體成員 壇-單目,9個: ! ~ ++ -- -負號 (類型) *指標 &取地址 sizeof長度 (結合方向:自右向左)酸-算術,5個: * / % + -減 味-位移,2個: << >> 灌-關係,6個: < <= > >= == 等於 != 不等於 味-位邏,3個: & 按位與 ^ 按位異或 | 按位或 落-邏輯,
Time of Update: 2018-12-07
在Linux中用C語言計時可以用很多方法。 1. 如果是想使用秒層級的技術,可用使用C語言庫<time.h>內建的clock()進行計時。如: #include <iostream> #include <time.h> using namespace std; int main() { clock_t start = clock(); //do some process here clock_t end = (clock() - start)
Time of Update: 2018-12-07
任何代碼的美麗不僅在於找到一個給定的問題的解決方案,但在它的簡單性,有效性,緊湊性和效率(記憶體)。設計的代碼比實際執行更難 。因此,每一個程式員當用C語言開發時,都應該保持這些基本的東西在頭腦中。 本文向你介紹規範你的C代碼的10種方法。 1. 避免不必要的函數調用 考慮下面的2個函數:void str_print( char *str ){ int i; for ( i = 0; i < strlen ( str ); i++){ printf("%c"
Time of Update: 2018-12-07
1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<signal.h> 4 5 #define N 100 //設定最大的定時器個數 6 7 int i = 0,t = 1; //i代表定時器的個數;t表示時間,逐秒遞增,先sleep(1),故初始為1 8 9 struct Timer //Timer結構體,用來儲存一個定時器的資訊10 { 11 int left_time; //還剩left_
Time of Update: 2018-12-07
可實現多個計時器以下的代碼是定時器庫的介面:timer.h#ifndef TIMER_H#define TIMER_H#include <time.h>typedef struct mytimer mytimer;typedef struct mytimer* timer;struct mytimer{ clock_t base_tm;float distm_second;};typedef int timerID;typedef enum timer_errors
Time of Update: 2018-12-07
一 安裝目的:不需支援php等。就html就行了。步驟:下載這些東西:Lenovo:~/下載/download4nginx$ lsmd5-1.3.0.tgz openssl-1.0.1c.tar.gz zlib-1.2.7.tar.gznginx-1.3.4.tar.gz
Time of Update: 2018-12-07
:
Time of Update: 2018-12-07
2008-5-7 12:02:001. 為什麼 fflush(stdin) 是錯的首先請看以下程式:#include <stdio.h>int main( void ){ int i; for (;;) { fputs("Please input an integer: ", stdout); scanf("%d", &i); printf("%d\n", i); } return
Time of Update: 2018-12-07
下載庫:http://www.gnu.org/software/libmicrohttpd/這裡有簡單的該庫介紹以及使用方法(簡略)。下載:$ svn checkout
Time of Update: 2018-12-07
我的記錄:1.指定了釋放器,就不會去直接調用解構函式。因為釋放器就一個。不指定的話解構函式就是釋放器.2.STL智能指標對內建內型的支援不如class:比如shared_ptr<char> s(new char[10]); memset(s, 0x00, 10);//error! 只能memset(s.get(), ....了。3. auto_ptr不能指定釋放器.#include "iostream"#include <tr1/memory>using
Time of Update: 2018-12-07
前幾天在項目中碰到的驗證問題,由於不適合用驗證控制項,所以只好自己寫了一個驗證方法,貼上來。。。 using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using