目前分類:C語言的嫩咖行 (15)

瀏覽方式: 標題列表 簡短摘要

資料來自於 http://jashliao.pixnet.net/blog/post/223492566-c-c++-%E6%B5%AE%E9%BB%9E%E6%95%B8%5B%E7%B2%BE%E5%BA%A6%E5%95%8F%E9%A1%8C%5D~%E5%9B%9B%E6%8D%A8%E4%BA%94%E5%85%A5%E5%87%BD%E6%95%B8

// 四捨五入 取到 小數點第 X 位

文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

原文來自 http://jashliao.pixnet.net/blog/post/223451341

 

文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

原文章來自 http://jashliao.pixnet.net/blog/post/219032153

#include <iostream>

文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

資料來源: http://jashliao.pixnet.net/blog/post/220855763
資料來源: http://delphi.ktop.com.tw/board.php?cid=168&fid=912&tid=60265

文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

出處 http://www.codedata.com.tw/social-coding/aes/
// 本程式由陳鍾誠將 jsaes: AES in JavaScript (作者: B. Poettering) 翻譯為 C 語言版,
文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

今天寫程式時卡位了,最主要是沒弄清楚sizeof()與strlen()的使用時機,後來問了jashliao,點通了我這小嫩咖,所以稍加記錄

而今天的主要情形是我使用C開檔,並寫入一段文字,儲存後離開,但去開檔看文字有寫入但後面多了一些亂碼,像是^@

文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

為什麼會有這個錯誤呢???

是因為你答應人家的事沒做到,怎麼說呢???

文章標籤

痞客興 發表在 痞客邦 留言(1) 人氣()

請檢查你有沒有加這個header

#include <stdlib.h>

文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

以下的範例是使用C語言來達成MySQL的連結,本文是參考http://codex.wiki/post/106065-844
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "/usr/include/mysql/mysql.h"
int main(){
  MYSQL mysql,*sock;
  MYSQL_RES *res;
  MYSQL_ROW row;
  char qbuf[160] = "select afield,bfield,cfield,dfield from tablename where tran = 1 limit 0,1";
  mysql_init(&mysql);
   if (!(sock = mysql_real_connect(&mysql,"localhost","dbuser","dbpassword","dbname",0,NULL,0))){
      fprintf(stderr,"Couldnt connect to engine!n%snn",mysql_error(&mysql));
      perror("");
      exit(1);
   }
   if(mysql_query(sock,qbuf)) {
      fprintf(stderr,"Query failed (%s)n",mysql_error(sock));
      exit(1);
   }
   if (!(res=mysql_store_result(sock))) {
      fprintf(stderr,"Couldnt get result from %sn", mysql_error(sock));
      exit(1);
   }
   printf("number of fields returned: %dn",mysql_num_fields(res));
   while((row = mysql_fetch_row(res))) {
      printf("afield:%s ,bfield:%s, cfield:%s, dfield:%s",row[0],row[1],row[2],row[3]) ;
      puts( "\nquery ok !n" ) ;
   }
 mysql_free_result(res);
 mysql_close(sock);
 exit(0);
 return 0;
}

編繹時我是使用下面命令

gcc -Wall mysql.c -o mysql `mysql_config --cflags --libs`
文章標籤

痞客興 發表在 痞客邦 留言(1) 人氣()

就是像這樣

mysql.c:(.text+0x25): 未定義參考到「mysql_init」

文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

就是要你在多包一層括弧,比如說

while (row = mysql_fetch_row(res)) {

文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

檢查看看你有沒有加這個header

#include <arpa/inet.h>

文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

轉貼自http://jashliao.pixnet.net/blog/post/207617839

文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()

如果你今天寫個C不帶任何參數,那看起來會像這樣

#include <stdio.h>

文章標籤

痞客興 發表在 痞客邦 留言(0) 人氣()